for own(...) loop (spin-off from Re: for..in, hasOwnProperty(), and inheritance)

John J Barton johnjbarton at johnjbarton.com
Tue Nov 8 14:26:01 PST 2011


On Tue, Nov 8, 2011 at 1:45 PM, Timmy Willison <timmywillisn at gmail.com> wrote:
> Yes, I think JS needs something like this.  This is new to no one here, but
> my main concern with using hasOwnProperty is the loss of performance, so I
> think it would be worth exploring more than just syntactic sugar.  But I
> don't know how realistic it is to hope for that.
> http://jsperf.com/hasownproperty-vs-for-in/4#c300

Added case Object.keys().forEach:

http://jsperf.com/hasownproperty-vs-for-in/7

Of course results depend more on browser than form of the loop...

jjb


More information about the es-discuss mailing list