Does javascript autobox?

后端 未结 3 726
攒了一身酷
攒了一身酷 2020-11-27 13:57

While working on another problem, I created this fiddle:

http://jsfiddle.net/tr2by/

function foo() {
    // console.log(_.isBoolean(this));
    conso         


        
3条回答
  •  情深已故
    2020-11-27 14:47

    Javascript boxes the this argument provided to call and apply in non-strict mode. From MDN:

    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.

提交回复
热议问题