Unfortunately, JSLint docs do not go into details than "does not expect to see", so we remain guessing. My own suspicion is that this simplifies type checking:
assert(typeof 3 === "number"); assert(typeof new Number(3) === "object");
If you mix two codes, your type checks become more complex:
if (typeof foo === "number" || foo instanceof Number) { … }
However, JSLint also comes across Object and Array constructors that do not make this distinction, so it could just be an authoring style in a coding style:
assert(typeof [] === "object"); assert(typeof new Array() === "object"); assert(typeof {} === "object"); assert(typeof new Object() === "object");
Edit:. Stephen's answer gives a great point - the equality operator without expressions (===). Numeric objects and numerical primitives will never be considered equal to this operator, even if their values are the same:
assert(3 !== new Number(3));
Ben Blank Dec 15 '08 at 18:22 2008-12-15 18:22
source share