4 ms·
Nice. I like use of the let/var/const keyword to disambiguate from the accidental `if (x = y)` when intending to use `==`.
by kdmccormick 7y ago
Nice. I like use of the let/var/const keyword to disambiguate from the accidental `if (x = y)` when intending to use `==`.
- codenirvana 7y agoOnly helps with const. Better use linting to avoid such issues.
- kdmccormick 7y ago> Only helps with const. Can you elaborate?
- wbercx 7y agoIf the `x` in the example was a const, it would throw an error because the code attempts to assign the value of `y` to `x`. You cannot assign a new value to a const.
- kdmccormick 7y agoWhat I'm saying is that you wouldn't accidentally type `let x = y` when you meant to type `x == y`