Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 列出IE8中的所有Array.prototype函数-_Javascript_Arrays_Loops_Internet Explorer 8_Prototype - Fatal编程技术网

Javascript 列出IE8中的所有Array.prototype函数-

Javascript 列出IE8中的所有Array.prototype函数-,javascript,arrays,loops,internet-explorer-8,prototype,Javascript,Arrays,Loops,Internet Explorer 8,Prototype,是否可以以跨浏览器友好的方式循环所有JavaScriptArray.prototype函数名?我知道这适用于IE9+和现代浏览器: var names = Object.getOwnPropertyNames(Array.prototype); names.forEach(function(name) { console.log(name); // function name }); 有没有办法在IE8和IE7中获得相同的列表?我试过: for(var key in Array.

是否可以以跨浏览器友好的方式循环所有JavaScript
Array.prototype
函数名?我知道这适用于IE9+和现代浏览器:

var names = Object.getOwnPropertyNames(Array.prototype);
names.forEach(function(name) {
    console.log(name); // function name
});   
有没有办法在IE8和IE7中获得相同的列表?我试过:

for(var key in Array.prototype) {
    console.log(key); // undefined
}

如果您试图查找版本9之前的IE浏览器中支持的内容,您可以假定它是IE9列表的一个子集,并筛选出不支持的内容

这是您在IE中获得的列表#9:

concat、constructor、join、length、pop、push、reverse、shift、slice、sort、拼接、tolocalString、toString、unshift

你可以测试一下-

<!doctype html>
<html lang="en">
<head>
<meta charset= "utf-8">
<title>Small Page</title>
<style>
</style>
<script>
onload= function(){
var testnames= ['concat', 'constructor', 'every', 'filter', 'forEach',
'indexOf', 'join', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce',
'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice',
'toLocaleString', 'toString', 'unshift'],
    L= 23;
    while(L){
        if(!(testnames[--L]in Array.prototype)) testnames.splice(L, 1);
    }
    document.getElementsByTagName('textarea')[0].value= testnames;
}
</script>

</head>
<body>

<p>   <textarea rows="8" cols="60"> </textarea>     </p>

</body>
</html>

小页
onload=函数(){
var testnames=['concat','constructor','every','filter','forEach',
“indexOf”、“join”、“lastIndexOf”、“length”、“map”、“pop”、“push”、“reduce”,
“reduceRight”、“reverse”、“shift”、“slice”、“some”、“sort”、“splice”,
“toLocaleString”、“toString”、“unshift”],
L=23;
while(L){
if(!(数组.prototype中的testnames[--L])testnames.splice(L,1);
}
document.getElementsByTagName('textarea')[0].value=testnames;
}


如果您谈论的是本机的、不可枚举的属性,那么没有。至少不需要手动创建一个可枚举列表,或者可能需要找到一些hackish
toString()
技巧。哈哈哈。