Baseline Widely available
NodeList
ì¸í°íì´ì¤ì forEach()
ë©ìëë 리ì¤í¸ ë´ì ê°ê°ì ê° ìì ëí´ ë§¤ê° ë³ìì ì§ì ë ì½ë°±ì ì½ì
ììë¡ í¸ì¶í©ëë¤.
NodeList.forEach(callback[, thisArg]);
Parameters
callback
ê°ê°ì ììì ëí´ ì¤ííë í¨ìë¡, 3ê°ì ì¸ì(arguments)를 ê°ìµëë¤:_ currentValue
_ : NodeListìì ì²ë¦¬ì¤ì¸ íì¬ ìì(element)ì
ëë¤.
currentIndex
NodeListìì ì²ë¦¬ì¤ì¸ íì¬ ììì ì¸ë±ì¤ì ëë¤.
listObj
forEach()
ê° ì ì©ëê³ ìë NodeList ê°ì²´ì
ëë¤.
thisArg
Optional
callback
ì ì¤íí ë this
ì ëì
í ê°ì
ëë¤.
None.
Examplevar node = document.createElement("div");
var kid1 = document.createElement("p");
var kid2 = document.createTextNode("hey");
var kid3 = document.createElement("span");
node.appendChild(kid1);
node.appendChild(kid2);
node.appendChild(kid3);
var list = node.childNodes;
list.forEach(function (currentValue, currentIndex, listObj) {
console.log(currentValue + ", " + currentIndex + ", " + this);
}, "myThisArg");
ê²°ê³¼ë ë¤ìê³¼ ê°ìµëë¤.
[object HTMLParagraphElement], 0, myThisArg [object Text], 1, myThisArg [object HTMLSpanElement], 2, myThisArgPolyfill
ì´ polyfill ì ES5 를 ì§ìíë 모ë ë¸ë¼ì°ì ìì ëìí©ëë¤:
if (window.NodeList && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = function (callback, thisArg) {
thisArg = thisArg || window;
for (var i = 0; i < this.length; i++) {
callback.call(thisArg, this[i], i, this);
}
};
}
ëë
if (window.NodeList && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = Array.prototype.forEach;
}
The above behavior is how many browsers actually implement NodeList.prototype.forEach (Chrome, for example).
ëª ì¸ì ë¸ë¼ì°ì í¸íì± See alsoRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4