Conditional
CONDITIONAL(조건문)
Always need ‘Comparison Operator’(비교 연산자)
- > more than
- < less than
- >= ane more
- <= and less
- === equal
- !== not equal
- Result is always ‘boolean’(true/false)
- else can be omitted depends on function.
To apply 2 conditions together, use ‘Logical Operator’(논리 연산자)
AND: &&
OR: ||
NOT: ! (falsy) **memorize
Number.isNaN(anything)
- In order to check NaN
- reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean
STRING METHODS = IMMUTABLE
- If you do string type + any different type, it becomes string type automatically.
length,
find value,
- if there is no value, it returns -1
lastIndexOf
- find index from the back and check the order from the front.
str.includes(searchValue)
- does not work at outdated browser and returns as Boolean
separate,
get certain values from the string,
- if start value is negative, it applies as 0.
- To see difference: reference: https://stackoverflow.com/questions/2243824/what-is-the-difference-between-string-slice-and-string-substring
Uppercase/Lowercase
Math
- Math.floor(x) = 내림;
- Math.ceil(x) = 올림;
- Math.round(x) = 반올림;
- Math.pow(base, exponent) = 제곱
trim() : remove space inside string
\n : new line