Evaluating Expression Syntax Flashcards
Differences between ‘Undefined’ and ‘Null’? When would a return value be ‘Undefined’ vs. ‘Null’?
- ‘Null’ is considered a value; can be assigned
- Typeof null is object; means ‘no object’
- ‘Null’ is return value for undefined objects or invalid expressions
- Undefined indicates that no value assigned
- Undefined is returned for primitives
Undefined != Null
True. ‘Null’ is a value and has type of object. Undefined has no value.
NaN != NaN
True. NaN can only be used in comparison expressions
Bool value of ‘Null’
False
Bool value of ‘Undefined’
False
ES6 method to check NaN?
Number.isNAN()
Default return value of a function if not specified?
Undefined
Are semicolons required after statements?
No, but they’re recommended for clarity
What comparison is safe to evaluate null?
Strict equality (returns 0 if type coersion is applied by ==)
Type of NaN?
Number
Type of Infinity?
Number (+ or - infinity)
In dot notation, everything to the left of a dot is ________
an object
Numeric value of ‘undefined’
NaN
Numeric value of ‘null’
0
ex: value of a null variable used in a calculation, value if type coercion is applied
What is the bool value of an object?
True