Y
Yan Huang
Hi,
Firefox's JS engine implementation has a built-in property
"__proto__". For example,
Fruit={__proto__:null, apple:true, pear:true, orange:true}
will create an object that I can rely to implementing a fruit type
decider:
Fruit['apple']; // true
Fruit['orange']; //true
Fruit['pecan']; //false
Fruit['toString']; //false
However, in other browsers such as Opera, which don't support
"__proto__" property, Fruit['toString'] will evaluate to a function,
which is converted to true. Therefore, I am wondering how can I avoid
accidentally accessing properties inherited from object in the
prototype chain?
Thanks,
Yan Huang
Firefox's JS engine implementation has a built-in property
"__proto__". For example,
Fruit={__proto__:null, apple:true, pear:true, orange:true}
will create an object that I can rely to implementing a fruit type
decider:
Fruit['apple']; // true
Fruit['orange']; //true
Fruit['pecan']; //false
Fruit['toString']; //false
However, in other browsers such as Opera, which don't support
"__proto__" property, Fruit['toString'] will evaluate to a function,
which is converted to true. Therefore, I am wondering how can I avoid
accidentally accessing properties inherited from object in the
prototype chain?
Thanks,
Yan Huang