Implementation of standard Array methods (introduced in ECMAScript 5th edition) and shorthand generics (JavaScript 1.8.5)
function isElement(element) { return element.nodeType === 1; } var children; // example #1 // using generic .filter() children = Array.filter(document.childNodes, isElement); // example #2 // using generic .slice() and array .filter() children = Array.slice(document.childNodes).filter(isElement);
All the following methods (except isArray) available in standard and generic shorthand notation:
Mutator | Accessor | Iteration | Other |
---|---|---|---|
pop | .concat() | .forEach() | .isArray() |
.push() | .join() | .every() | |
.reverse() | .slice() | .some() | |
.shift() | .indexOf() | .filter() | |
.sort() | .lastIndexOf() | .map() | |
.splice() | .reduce() | ||
.unshift() | .reduceRight() |