|
|
|
|
|
by renekooi
4016 days ago
|
|
querySelectorAll returns a NodeList instead of a real array, so you can't call things like `.forEach` on the result. `[].slice.call(x)` turns x into an array, so that becomes [].slice.call(document.querySelectorAll(...)).forEach(function () {})
Because a lot of array methods are "generic", i.e. operate on array-like objects instead of just arrays, that can be "compacted" to [].forEach.call(document.querySelectorAll(...), function () {})
but neither are very nice. |
|