When determining if something is false, the toBoolean function references a list of falsy values. If the object in question is on that list, the result is false. If it isn’t on the list, the result is true.
The rules that I'm about to suggest to you only apply…if you are actually and legitimately doing a ToBoolean,…which means you're going to have to figure out…the places where that happens and the places where…it looks like it happens but it doesn't.…These rules only apply if ToBoolean is actually invoked.…I will teach you the ways to avoid that,…but you should be aware that there are lots of places…where you can get tricked into thinking…that it happened when it didn't.…What does ToBoolean say?…It's basically a simple table.…
It's kind of like a look-up list.…And it defines falsy values.…This is kind of interesting,…the word falsy and truthy get thrown around.…
Note: This course was created by Frontend Masters. It was originally released on 8/29/2015. We're pleased to host this training in our library.
- Primitive types: undefined, string, number, boolean, and object
- Special values: NaN and negative zero
- Natives: Regex and date
- Functions: toString, toNumber, and toBoolean
- Implicit coercion
- Explicit coercion
- Strings, numbers, and booleans
- Operators: Double equal and triple equal