Can (a == 1 && a == 2 && a == 3) Ever Evaluate to 'true'? stackoverflow.com/q/48270127/3951 (Not very useful but it turns out, yes, it's possible to make it happen in JavaScript.)


let a = {foo: 0, valueOf: function () { return ++this.foo }}


Frankly I find it a useless, "lawyer" question - it is one in a gazillion to hit it in real life, less than 10 people will ever benefit of this knowledge, it bloats corner-case-theoretical questions, but it is considered pro-knowledge. Useful if you will create ES-10, probably...


On of the tricky question I ever seen!!


JS c'est plus fort que toi ^^


That's why you gotta === every time! Like the billboard says: "==: not even once".


a = true. Hilarious type juggling ensues.


it should be incrementing object field and overriding valueOf ) but I knew that it's possible, that is always easier


thats really cool haha, so a friend of mine made a nice answer in C++ : struct{ bool operator== (const int content) const { return true } } a; int main(){ if (a == 1 && a == 2 && a ==3) printf("worked"); return 0 }


United States Trends
Loading...

Something went wrong.


Something went wrong.