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

Quildreen Motta quildreen at gmail.com
Tue Nov 8 17:51:36 PST 2011


On 08/11/11 21:36, Brendan Eich wrote:
> Ignoring performance, a lot of stylish JS hackers use Object.keys(o).forEach. How many run into the wrong |this| (arguments/break/continue/return)? Not clear. Something to study.

Well, I use Object.keys, etc, a lot thorough my code. I can't remember a 
case where I forgot to pass the `thisObject' parameter to the 
`forEach'/`map' call in the last months, though it was weird when I 
transitioned to a more functional coding style.

I guess the number of cases I was bitten by the wrong |this| in the 
beginning is about the same number of ASI issues I ran into when I 
started using destructuring assignments for arrays. I'd assume that has 
a lot to do with coding habits — writing without properly thinking.

`reduce' and `reduceRight' don't have a `thisObject' argument. Why are 
they the only odd ones?


More information about the es-discuss mailing list