Reputation: 1463
Is it possible for this prototype function to return false or is it a pointless check that will always return true?
if (!Date.prototype.hasOwnProperty("foo")) {
Date.prototype.foo = function () {
var date = this;
if (!date) {
return false;
}
return true;
}
}
Upvotes: 2
Views: 76
Reputation: 4361
The this
keyword in JavaScript is only undefined
if strict mode is enabled. Otherwise, it will reference the window
object by default, unless any of the following are true:
new
operatorthis
using call()
or apply()
Upvotes: 4