引擎盖下的Array.prototype.concat() [英] Array.prototype.concat() under the hood
问题描述
如何查看函数concat中的代码?它是如何做的呢?有没有人有一个代码的副本或在浏览器控制台中看到它的方法?
How do I see what code is inside the function concat? How does it do what it does? Does anyone have a copy of the code or a way to see it in the browsers console?
console.dir不允许我访问过去
console.dir does not give me access past
console.dir(Array.prototype.concat);
function concat() { [native code] }
arguments: null
caller: null
length: 1
name: "concat"
__proto__: function Empty() {}
<function scope>
我不知道或不知道怎么检查这个但是必须有办法挖掘进入javascript函数
I can't or don't know how to inspect this but there must be a way to dig into javascript functions
推荐答案
数组
附带JavaScript,所以它取决于你的JavaScript引擎如何实现它。 JS引擎可以以任何方式自由实现它。有可能它不使用JavaScript,因为它可能太慢或者可能不可能,因为你需要一个JavaScript引擎,它具有你试图实现它的功能(参见bootstrapping )。
Array
comes with JavaScript, so it depends on your JavaScript engine how it is implemented. A JS engine is free to implement it in any way. Chances are that it doesn't use JavaScript because that might be too slow or might not be possible because you'd need a JavaScript engine with the feature you're trying to implement to implement it (see bootstrapping).
在大多数浏览器中,有许多JavaScript函数用C / C ++实现。以下是Chrome / Chromium系列浏览器的示例: https://cs.chromium.org/chromium/src/v8/src/builtins/builtins-array。 cc?q = Array.prototype.concat& sq = package:chromium& dr = C& l = 635
In most Browsers, many JavaScript functions are implemented in C/C++. Here is an example from the source of the Chrome/Chromium family of browsers: https://cs.chromium.org/chromium/src/v8/src/builtins/builtins-array.cc?q=Array.prototype.concat&sq=package:chromium&dr=C&l=635
ArrayConcatJS
在Chrome中的 InstallFunctions
调用中变为 Array.prototype.concat
引导程序
。感谢您的光临 apsillers 。
ArrayConcatJS
becomes Array.prototype.concat
in the InstallFunctions
call in Chrome bootstrapper
. Kudos for this go to apsillers.
<$ c $可在此处找到 Rhino引擎的c> Array.concat :< a href =https://github.com/mozilla/rhino/blob/master/src/org/mozilla/javascript/NativeArray.java =nofollow noreferrer> https://github.com/mozilla/rhino方法中的/blob/master/src/org/mozilla/javascript/NativeArray.java js_concat()
(如1322)。
Array.concat
for the Rhino engine can be found here: https://github.com/mozilla/rhino/blob/master/src/org/mozilla/javascript/NativeArray.java in the method js_concat()
(like 1322).
这篇关于引擎盖下的Array.prototype.concat()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!