3 ms·
I find Avoid Comparing to true and false a little pedantic and can someone explain how it is "... bad as it's ambiguous"?
by hartror 15y ago
I find Avoid Comparing to true and false a little pedantic and can someone explain how it is "... bad as it's ambiguous"?
- taitems 15y agoI'll put my hand up for that mistake. I think the word I was looking for was "redundant", and not "ambiguous". Following the other concept of prefixing your booleans with "can" "has" and "is", your variable names should be self explanatory. if (isSelectable === true) { ... } versus: if (isSelectable) { ... } It's a shorthand method, similar to why you would use int++; instead of int = int + 1;
- joeyespo 15y agoI was just wondering the same thing. Thought there was some magic javascript concept I somehow missed. Glad you answered! Good article, bookmarked it for reference/a checklist.