I've just had a look at it and where this issue comes up in the book
there's a new variable declared (like on page 153). No need to pass
the argument this way, moreover not that easy to mistype:

  for ( var j in properties ) { (function(){
    var i=j;
    ...

I can't believe no one has spotted this: http://www.apress.com/book/errata/275

On Dec 18, 4:53 pm, Pablo Fernandez <fernandezpabl...@gmail.com>
wrote:
> That did it, although I had to add this too
>
> -- }).call(this,i);
>
> in order to pass the parameter
>
> Thanks Balazs!!!
>
> On 18 dic, 12:29, Balazs Endresz <balazs.endr...@gmail.com> wrote:
>
> > Oops, I didn't notice it: you have to pass the `i` variable too:
> >   for ( var i in properties ) { (function(i){
>
> > That's why you need the closure at all. Without that you will get the
> > last property from all getters.
>
> > The reference of `this` will always change if you put it in an
> > additional function, doesn't matter if it's inside an instantiated
> > object. Well, you can call that either design error or feature too :)
>
> > On Dec 18, 4:18 pm, Pablo Fernandez <fernandezpabl...@gmail.com>
> > wrote:
>
> > > another thing... why inside the anonymous function 'this' refers to
> > > 'window' ??  it's totally misleading...

Reply via email to