javascript中函数和对象没有区别吗?

Is there no difference between function and objects in javascript?

书中Javascript: The good parts作者使用如下代码创建对象

 if (typeof Object.create !== 'function') {
 Object.create = function (o) {
 var F = function () {};
 F.prototype = o;
 return new F();
 };
 }
 var another_stooge = Object.create(stooge);

该函数旨在创建一个对象,但它 returns 是一个函数。 (参考 - 第 3 章,页码:22)

Is there no difference between function and objects in javascript?

函数是可以调用的对象,它们是用不同的语法创建的。

The author uses following code to create objects […]

我们不应该再这样了。 Object.create 已标准化并在几乎所有浏览器中实施。

无论如何,我们不应该试图通过查看这个可怕的 polyfill 来理解 Object.create 的作用。我们应该将 Object.create 视为语言原语(如果需要,我们可以根据它定义 new 运算符)。

The function is meant to create an object but it returns a function instead.

不,不是。它不 return F,它 return new F(),这是 调用 F 的结果(作为构造函数) .