Skip to content Skip to sidebar Skip to footer

Why Checking Null In Array.prototype.forEach()?

In the MDN polyfill for Array.prototype.forEach() // Production steps of ECMA-262, Edition 5, 15.4.4.18 // Reference: http://es5.github.io/#x15.4.4.18 if (!Array.prototype.forEach)

Solution 1:

Because you can pass a custom value for this in javascript by using call()/apply()/bind() like

[].forEach.call(null, function(){})

Post a Comment for "Why Checking Null In Array.prototype.forEach()?"