Y
Yan Huang
I have got bizarre results from the following sequence of simple code
snippet:
o={x:1,f:function (){return this.x}}
//Object
o.f()
//1
o.f.apply(o)
//1
o.f.apply === o.f.apply.apply
//true
o.f.apply.apply(o)
//TypeError: Function.prototype.apply was called on [object Object],
which is a object and not a function
All results are as expected except the last one. Anybody can help
explain this?
Thanks,
Yan Huang
snippet:
o={x:1,f:function (){return this.x}}
//Object
o.f()
//1
o.f.apply(o)
//1
o.f.apply === o.f.apply.apply
//true
o.f.apply.apply(o)
//TypeError: Function.prototype.apply was called on [object Object],
which is a object and not a function
All results are as expected except the last one. Anybody can help
explain this?
Thanks,
Yan Huang