Why does the following work:
function sum(a,b) { return a + b; }
var result = sum.call(null,3,4); // 7
Why is result defined? I am invo
Its not. NULL in this case specifies to what object the this
keyword is bound to. In your method, by setting it to NULL it will either not have a this
variable binding or it will be bound to the function itself or the window.
Since you're not using any variables or functions that are accessed via this
, then there's no need to use the call method ... you can just use sum(3,4)