var myFunc = new Object(function myFunc () {}) 和 function myFunc () {} 有什么区别?

What is the different between var myFunc = new Object(function myFunc () {}) and function myFunc () {}?

我不知道您可以使用新对象创建函数:

var myFunc = new Object(function myFunc () {})

查看控制台,它似乎与:

function myFunc () {}

是否有理由使用 new 对象创建函数?

根据 Object(...) documentation:

The Object constructor creates an object wrapper for the given value. If the value is null or undefined, it will create and return an empty object, otherwise, it will return an object of a Type that corresponds to the given value. If the value is an object already, it will return the value.

函数是对象,因此它只是 return 函数。 new Object(...) 部分是 no-op。所以代码基本上就是:

  var myFunc = function myFunc() { }

也就是barely equal to a function declaration