Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var forEach = function (array, callback, scope) {
- for (var i = 0; i < array.length; i++) {
- callback.call(scope, i, array[i]); // passes back stuff we need
- }
- };
- // Usage:
- // optionally change the scope as final parameter too, like ECMA5
- var myNodeList = document.querySelectorAll('td:nth-child(3) > a');
- forEach(myNodeList, function (index, value) {
- console.log(index, value.textContent); // passes index + value back!
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement