Is it possible to loop through all JavaScript Array.prototype function names in a cross-browser friendly way? I know this works in IE9+ and modern browsers:
var names = Object.getOwnPropertyNames(Array.prototype);
names.forEach(function(name) {
console.log(name); // function name
});
Is there a way to get the same list in IE8 & IE7? I tried:
for(var key in Array.prototype) {
console.log(key); // undefined
}
If you are trying to find what is supported in an IE browser before version 9, you can assume that it is a subset of IE9’s list and winnow out the ones not supported.
This is the list you get in IE before #9:
concat, constructor, join, length, pop, push, reverse, shift, slice, sort, splice, toLocaleString, toString, unshift
You can test it-