var x= 1;
Number.prototype.test = function () { return this };
x.test() === x.test() // false
Why does the === test return false?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because
thiswill be a Number object, not the original primitive number value, and comparing two equally created objects will always return false:If you’re looking for a fix, cast
thisto a number