I'm Collecting JavaScript Classes prototypes that make it compatible to old browsers never mind of that but what i wonder while collecting them that the Developer At Mozila comparing the Array to null i can see that is non since but maybe I'm wrong and there is an explanation for that ???
if (!Array.prototype.every) {
Array.prototype.every = function(fun /*, thisp */) {
"use strict";
if (this == null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun != "function")
throw new TypeError();
var thisp = arguments[1];
for (var i = 0; i < len; i++) {
if (i in t && !fun.call(thisp, t[i], i, t))
return false;
}
return true;
};
}
at this line
if (this == null)
this is refers to the Array
This code at Mozila
Kindly i need an explanation is that a logic to compare a Array to a null even if i know that "this" which is refer to a must array type not a variable can be array or null ?? what you think ??