In Douglas Crockford\'s book \"Javascript: The Good Parts\" he provides code for a curry
method which takes a function and arguments and returns that function with
From MDN:
thisArg The value of this provided for the call to fun. Note that this may not be the actual value seen by the method: if the method is a function in non-strict mode code, null and undefined will be replaced with the global object, and primitive values will be boxed.
Hence, if the method is in non-strict mode and the first argument is null
or undefined
, this
inside of that method will reference Window
. In strict mode, this is null
or undefined
. I've added a live example on this Fiddle.
Furthermore passing in null
or undefined
does not do any harm in case the function does not reference this
at all. That's probably why Crockford used null
in his example, to not overcomplicate things.