[英]How can I iterate over Array.prototype functions
I want to wrap all Array functions in array object, but in console 我想将所有Array函数包装在数组对象中,但是在控制台中
>>> Array.prototype
[]
>>> [].prototype
undefined
but when I type Array.prototype
in console it show all functions in autocomple, how can I get those functions? 但是当我在控制台中键入Array.prototype
它显示自动填充中的所有函数时,我该如何获得这些函数? Where are they hidden? 他们藏在哪里?
do you mean: 你的意思是:
var arrObj = Object.getOwnPropertyNames(Array.prototype);
for( var funcKey in arrObj ) {
console.log(arrObj[funcKey]);
}
Using ECMAScript 6 (ECMAScript 2015), you can simplify a bit: 使用ECMAScript 6(ECMAScript 2015),您可以简化一下:
for (let propName of Object.getOwnPropertyNames(Array.prototype)) {
console.log(Array.prototype[propName]);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.