cameronstark
1/25/2018 - 5:26 AM

forEach for queryselector

forEach for queryselector

// REF: https://css-tricks.com/snippets/javascript/loop-queryselectorall-matches/

let forEach = function (array, callback, scope) {
  for (var i = 0; i < array.length; i++) {
    callback.call(scope, i, array[i])
  }
}

// const myNodeList = document.querySelectorAll('li')
// if(myNodeList.length > 0) {
//  forEach(myNodeList, function (index, value) {
//    console.log(index, value)
//  })
// }

export default forEach