jsuwp 3-19 ~ 3-27 Types and javascript
3-19 Types and javascript
bigword alert : Dynamic typing
- you don’t tell the engine what type of data a variable holds
- it figures it out while your code is running
3-20 Primitive types
bigword alert : Primitive type
- a type of data that represents a single value
- (not a object)
List of primitive types in javascript
undefined
lack of existence(note that you shouldn’t set avariable to this)null
lack of existence(you can set a variable to this)boolean
true or falsenumber
floating point numberstring
sequence of characterssymbol
new feature in ES6, 略
3-21 Operators
bigword alert : operator
- a special function that is syntactically (written) differently
1 |
|
- recall : postfix, prefix, infix
3-22 Operator precedence and associativity
operator precedence and Associativity table
bigword alert : operator precedence
- which operator function get called first
- higer precedence wins
bigword alert : associativity
- when function have the same precedence, what order operator function get called in
- left-to-right or right-to-left
1 |
|
3-24 Coercion
bigword alert : Coercion
- converting a value from one type to another
1 |
|
3-25 Comparison operator
- Recalls : associativity, operator, coercion
1 |
|
1 |
|
- In javascript, == will do coercion
- Strict equality (===) is going to save your life !!
- 99% of the time, use ===
3-27 Existence adn Booleans
1 |
|