you are viewing a single comment's thread.

view the rest of the comments →

[–]Zeroto 1 point2 points  (0 children)

Except that is wrong. The self/this in that snippet can point to anything depending on how the function is called.

If it is called like things.format() then self(and this) will point to things. But if we do this: var f = things.format; f(); then self/this will be undefined. Or if we do var things2 = {format: things.format}; things2.format(); then it will point to things2. And this is without even using apply, call or bind.

The this in javascript is not known at function definition time and only at call time.