Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #17410 > unrolled thread
| Started by | JJ <jaejunks@glegooilma-swapit.com> |
|---|---|
| First post | 2012-12-02 16:57 +0000 |
| Last post | 2012-12-02 16:57 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.javascript
Truly hidden object property? JJ <jaejunks@glegooilma-swapit.com> - 2012-12-02 16:57 +0000
| From | JJ <jaejunks@glegooilma-swapit.com> |
|---|---|
| Date | 2012-12-02 16:57 +0000 |
| Subject | Truly hidden object property? |
| Message-ID | <XnsA11E4D34FDCjaejunksglegooilma@0.0.0.23> |
When opening an RSS URL using Opera web browser, Opera will preview it
like a web page. Opera processes the RSS and store the RSS data in
"opera.feed". The interesting thing is that the "feed" property, even
though it's enumerable, it's not included in "Object.getOwnPropertyNames
(opera)" result. Here's some code to show what I meant (on previewed
RSS).
var a=Object.getOwnPropertyNames(opera);
console.log(a.join('\n'));
/* result:
renderingMode
stpVersion
buildNumber
version
collect
postError
getLocaleString
addEventListener
removeEventListener
defineMagicFunction
defineMagicVariable
getOverrideHistoryNavigationMode
setOverrideHistoryNavigationMode
getPreference
getPreferenceDefault
setPreference
FeedEntry
Feed
deleteDatabase
*/
//note: opera.Feed !== opera.feed
//opera.Feed is a constructor, and opera.feed is an object
var a=Object.getOwnPropertyDescriptor(opera,'feed');
console.log(JSON.stringify(a));
//result: {"enumerable":true,"configurable":true}
//note: descriptor's "get" and "set" are Opera native functions
//"feed" property isn't an inherited property,
//since it's a direct descendant of Object.
console.log(opera.__proto__ === Object.prototype);
//result: true
"Object.getOwnPropertyNames" should list all properties, whether they're
enumerable or not.
Any property created using "Object.__defineGetter__" should also be
included in "Object.getOwnPropertyNames" result.
I thought it was done using "opera.defineMagicVariable", but it can't
create a variable as a property of other object. For example:
//this is ok
opera.defineMagicVariable('abc',
function(){ //getter
return 123;
},
function(){ //setter
}
);
console.log(typeof abc); //number
//this is not ok
var abc={};
opera.defineMagicVariable('abc.def',
function(){ //getter
return 123;
},
function(){ //setter
}
);
console.log(typeof abc); //object
console.log(typeof abc.def); //undefined
The "call" and "apply" can't also be used on "opera.defineMagicVariable"
since its "this" must be global context like "setTimeout".
How is this truly hidden property possible?
Is it one of Opera magic?
Back to top | Article view | comp.lang.javascript
csiph-web