Hacker News new | ask | show | jobs
by wambotron 4442 days ago
I think the answer to "can something be fuzzy equal to one value and strictly equal to another in JS?" has an easy answer that doesn't take much effort to find. This might be cooler in another language, though.

var b = 2;

b == '2'; // true

b === 2; // true

2 comments

I think you missed a bit of his point which was to make that exact expression evaluate as true

(b == 1 && b===2 && b === herpderp)

This is what I was gonna say! I don't know much JS, but after @sgdesign 's recent primer, the answer to the first two conditions seems obvious, b=="2" and b===2. Herpderp is just a cop out, since you could have infinite other variables that b equals, if you set the value to the same thing!
Except the question was b==1 && b===2