Evaluating Expression Syntax Flashcards
(26 cards)
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
Name 6 things considered ‘falsey’
false, 0, NaN, ‘ ‘, undefined, null
Operator to concat strings
+
Escape character
\ backslash
What type of expression is…
{ foo: bar(3, 5)}
Object literal. Expression that looks like a statement
What type of expression is…
function foo( ){ }
Named function expression
let n = “25”
- Convert to number with single operator
- Convert to number with method
- +n //not ideal because it’s unclear
2. number(n) //verbose but clear
Preferred quote style for JS?
Single
Preferred quote style for HTML?
Double
Quote style for JSON?
Double (required)