4 ms·
It's a poor example when testing for truthiness because it can be written more concise. Imagine you're checking if the value is equal to a number or string. Pl
by reledi 10y ago
It's a poor example when testing for truthiness because it can be written more concise.
Imagine you're checking if the value is equal to a number or string. Placing the variable on the RHS avoids accidentally assigning a value to it if you mistype the comparison operator.
This is called Yoda conditions: https://en.m.wikipedia.org/wiki/Yoda_conditions https://en.m.wikipedia.org/wiki/Yoda_conditions
Edit: Many people already commented the same thing. Sorry for the noise!