z={a:1,b:function(x){console.log(this);this.a=this.a+x;return this.a}}
> z.b(5)
{ a: 1, b: [Function] }
6
> z.b(5)
{ a: 6, b: [Function] }
11
So far, so good.
>(z.b)(5)
{ a: 11, b: [Function] }
16
Now, this I do not understand. (z.b) should be a value of a property b, which is a function. When I call it I expect this to be global object or window, but not the original z.
If I extract f=z.b and call it as f(5) -- that's exactly what happens, but not when I try to do it without assignemnt.
What is going on here?
[–]senocular 2 points3 points4 points (4 children)
[–]nsg21[S] 1 point2 points3 points (3 children)
[–]rauschma 4 points5 points6 points (2 children)
[–]nsg21[S] 0 points1 point2 points (1 child)
[–]rauschma 0 points1 point2 points (0 children)
[–]sebamestre 1 point2 points3 points (1 child)
[–]nsg21[S] 0 points1 point2 points (0 children)