Created
July 13, 2018 06:46
-
-
Save bolerap/b4770fc17df5210f4dcde483d0a23242 to your computer and use it in GitHub Desktop.
Javascript data types, while null == undefined is true
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 0. Primitive data types (6): Boolean, Null, Undefined, String, Number, Symbol | |
// | |
// 1. Truely and Falsy value in javascript | |
// - Falsy (6 falsy value): false, 0, '' (empty string), null, undefined, NaN | |
// - Truely: All other values that differ 6 falsy value above. | |
// | |
// 2. Type Coerce | |
// - When checking equality (==) javascript will coerce operands to the same data type before compare. | |
// - With operator === javascript only compare operands when they are the same data type. Immediately return false when differ. | |
// | |
// 3. Type cast | |
// - String(), Number(), Boolean() | |
// | |
// 4. null and undefined | |
// - null has type object (this considered as an error in javascript), undefined has type undefined (typeof undefined) | |
// - null == undefined: return true because both is falsy values | |
// - null === undefined: returne false because null has type object while undefined has type undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment