3 ms·
The implicit coercion rules don't matter if you make sure to convert the types explicitly, but then you're just relying on your discipline. You might be able to
by slikts 8y ago
The implicit coercion rules don't matter if you make sure to convert the types explicitly, but then you're just relying on your discipline. You might be able to pull it off individually, but it starts mattering more when working with other people.
Also, from a brief glance at your code example, you don't seem to have caught up with other current best practices like linting or modules.
- deleted 8y ago[deleted]
- awestroke 8y agoYou don't have to rely on discipline, you can use tooling like ESLint or Flow to make sure there are no implicit conversions in the codebase.
- TheDong 8y agoeslint absolutely can't figure out whether '==' will implicitly convert its arguments or not. The type information simply is not there.
- awestroke 8y agoeslint can disallow == for anything but `== null`. Problem solved. https://eslint.org/docs/rules/eqeqeq https://eslint.org/docs/rules/eqeqeq
- TheDong 8y agoThis thread is about not using `===`; it's obviously true that it can be disallowed entirely, but it can't be allowed based on whether or not it will coerce, which was the context of the thread.