If ... else statements
truthy and falsy expressions
comparing === to ==
The Ternary Operator
Block Scope
Loops: for, while, do...while
Conditionals Using if()
===: equal
!==: not equal
Truthy and Falsy
Falsy | Truthy |
false |
Everything NOT falsy 0.5 "0" String |
*floating point bug in JS
use parenthesis, toFixed(...), and string to number to fix this bug
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed
if ... else
don't forget to use braces{}
Comparing === to ==
double equal sign: JS will try to convert Number to String
Triple equal sign: JS will not change its Type
The Ternary Operator
(Condition) ? true-statement : false-statement;
let message = (price > 10) ? 'expensive' : 'cheap';
Block Scope using let
Block scope: let, const
Global scope: var
Looping with for()
be careful to not to stuck in an infinite loop
Looping with while()
Do ... while() loop
'Study > Coding' 카테고리의 다른 글
Objects (0) | 2020.02.17 |
---|---|
Functions (0) | 2020.02.12 |
Types and Operators (0) | 2020.02.07 |
Variables and Constants (0) | 2020.02.07 |
File의 두가지 형식, Binary / Text (0) | 2018.11.02 |