All values are either truthy or falsy, but most values are loosely equal to neither true nor false. Truthy values are even more unlikely to be loosely equal to true. Objects are always truthy, but their primitive representation may be loosely equal to false."0" (and other string literals that are not "" but get coerced to 0) is truthy but loosely equal to false.NaN, undefined, and null are falsy but not loosely equal to false.In general, falsiness and = false differ in the following cases: Comparing strings and booleans results in both being converted to numbers, and they both become 0, so = false is true. However, when comparing with false, which is a primitive, is also converted to a primitive, which is "" via (). It's truthy, because all objects are truthy. is truthy, but it's also loosely equal to false. log ( " is truthy" ) } if ( = false ) // is truthy // = false Object.prototype._lookupSetter_() Deprecated.Object.prototype._lookupGetter_() Deprecated.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |