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;
}
}
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
operator this
using call()
or apply()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.