On 9/10/07, Brendan Eich <[EMAIL PROTECTED]> wrote:
> On Sep 10, 2007, at 2:21 PM, Garrett Smith wrote:
>
> > And my point was that it appears to duplicate functionality of
> > hasOwnProperty in a differently named method.
>
> The two functions are different:
>
> js> var Op = Object.prototype;
> js> Op.foo = 42;
> 42
> js> print(Op.hasOwnProperty('foo'), Op.propertyIsEnumerable('foo'));
> true true
> js> print(Op.hasOwnProperty('toString'), Op.propertyIsEnumerable
> ('toString'));
> true false
>
> > The fact that the method
> > was called propertyIsEnumerable instead of isPropertyEnumerable is not
> > great, but the way propertyIsEnumerable is designed is confusing to
> > developers.
>
> I've never heard that complaint directly, or in a
> bugzilla.mozilla.org report. Can you cite complaints anywhere on the
> web? I believe you, but it would be good to have evidence.
>
> > propertyIsEnumerable and hasOwnProperty are interchangeable (in
> > conforming hosts, not JScript)
>
> This statement is false.
>
You're example clarifies that. I see how it could be useful, in fact,
for examining a prototype chain to filter out extra stuff that got
shoved in.

For user-defined objects, propertyIsEnumerable and hasOwnProperty are
interchangeable.

var obj = {
    Garrett : "monkeybrains"
    ,borked : "javascript" // transitivity fixed :-)
    ,toString : function() { return "an enumerable prop"; }
    ,valueOf : function() { return 2; } // also enumerable.
};

Is there a value for s where the following is true:
(obj.hasOwnProperty( s ) != obj.propertyIsEnumerable( s ))

Garrett

> /be
>


-- 
Programming is a collaborative art.
_______________________________________________
Es4-discuss mailing list
Es4-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es4-discuss

Reply via email to