Javascript 为什么F.prototype属性在日志中不一致

Javascript 为什么F.prototype属性在日志中不一致,javascript,function,prototypal-inheritance,propertydescriptor,Javascript,Function,Prototypal Inheritance,Propertydescriptor,因此函数属于Object类型,因此可以具有属性。默认情况下,函数F将具有名称、长度和原型属性,并且原型属性将默认设置为具有一个键“构造函数”的对象,该键指向函数本身。i、 e function F() { this.foo = "bar"; } /* default prototype F.prototype = { constructor: F}; */ 这可以通过运行console.log(Object.getOwnPropertyDescriptors(F.prototype))哪

因此函数属于Object类型,因此可以具有属性。默认情况下,函数F将具有名称、长度和原型属性,并且原型属性将默认设置为具有一个键“构造函数”的对象,该键指向函数本身。i、 e

function F() {
  this.foo = "bar";
}

/* default prototype
F.prototype = { constructor: F};
*/
这可以通过运行
console.log(Object.getOwnPropertyDescriptors(F.prototype))哪个输出

 {
    constructor: {
        value: [Function: F],
        writable: true,
        enumerable: false,
        configurable: true
    }
 } 
F.prototype.constructor==F
的计算结果为true

令人困惑的是
console.log(F.prototype)
将只输出一个空对象
F{}

类似地
console.log(Object.getOwnPropertyDescriptors(F))将产生以下结果:

{
length: { value: 0, writable: false, enumerable: false, configurable: true },
  name: {
    value: 'F',
    writable: false,
    enumerable: false,
    configurable: true
  },
  prototype: {
    value: F {},
    writable: true,
    enumerable: false,
    configurable: false
  }
}

为什么当我期望像
{constructor:[Function:F]}
这样的东西时,它们返回一个空对象
F{}

因为
可枚举:false
控制台.log(typeof F=='Function')
。构造函数在你调用
new
时生成对象。哇,我想你刚才指出了
Object.getownPropertyDescriptor
的创建者不理解构造函数不是对象。Crazy.because
enumerable:false
console.log(typeof F=='function')
。构造函数在你调用
new
时生成对象。哇,我想你刚才指出了
Object.getownPropertyDescriptor
的创建者不理解构造函数不是对象。疯子