關於JavaScript中[native code]
一、總結
一句話總結:
1、[native code] 意思已經很明確了:是 native 的代碼實現的 built-in 函數,而不是 JavaScript 代碼
2、An implementation-dependent representation of the function is returned.
二、關於JavaScript中[native code]
轉自或參考:
[native code] 意思已經很明確了:是 native 的代碼實現的 built-in 函數,而不是 JavaScript 代碼。
但這並不是語言標准規定的。只是恰好 Firefox、Chrome 都這么干而已。
語言標准里有說:15.2.4.2 Function.prototype.toString()
An implementation-dependent representation of the function is returned.
它是 implementation-dependent 的。
說到 V8,可以看 v8natives.js 第 1710 行附近的 FunctionSourceString 函數:return 'function () { [native code] }';