4

クロムでは、

(function(){}).__proto__

function Empty() {}

だから私は期待していたでしょう

new Function();

であるがfunction Empty() {}、代わりにそうであるfunction anonymous() {}

どこで見つけることができますfunction Empty() {}か? それは中FunctionObjectどこかにありますか?

4

3 に答える 3

6

これらの名前は、それらの識別子でアクセスできるという意味ではありません。

関数のプロトタイプは起動時に名前が設定されます。.nameその関数には名前が設定されていますが、実際にはそれを公開して公開する以外の目的はありません.toString()

例として、名前new Function()単に. 空の文字列も同様です。繰り返しますが、それはあまり目的を果たしません。.toString().name

于 2012-09-01T11:32:26.663 に答える
6

空の関数オブジェクト (名前はEmpty) は、 のプロトタイプですFunction

Function.prototype.toString() === "function Empty() {}"

Object.getPrototypeOf(new Function()).toString() === "function Empty() {}"
于 2012-09-01T11:22:08.297 に答える
2

Empty は Function のプロトタイプの名前です。Chrome コンソールから:

dir(Function)
  function Function() { [native code] }
  arguments: null
  caller: null
  length: 1
  name: "Function"
    prototype: function Empty() {}
    __proto__: function Empty() {}
    apply: function apply() { [native code] }
    arguments: null
    bind: function bind() { [native code] }
    call: function call() { [native code] }
    caller: null
    constructor: function Function() { [native code] }
    length: 0
    name: "Empty"
    toString: function toString() { [native code] }
    __proto__: Object
于 2012-09-01T11:27:10.933 に答える