Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can (a==1 && a==2 && a==3) ever evaluate to true? #26

Open
likui628 opened this issue Jul 1, 2022 · 1 comment
Open

Can (a==1 && a==2 && a==3) ever evaluate to true? #26

likui628 opened this issue Jul 1, 2022 · 1 comment
Labels
JS javascript

Comments

@likui628
Copy link

likui628 commented Jul 1, 2022

Is it ever possible that (a== 1 && a ==2 && a==3) could evaluate to true in JavaScript?

@luckept
Copy link
Member

luckept commented Jul 1, 2022

of course, my old baby!

const a = { val: 1 };
a[Symbol.toPrimitive] = () => a.val++;
console.log(a == 1 && a == 2 && a == 3);

@Hongbusi Hongbusi added the JS javascript label Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JS javascript
Development

No branches or pull requests

3 participants