1. &&
AND 연산
a && b
a가 true면 b, a가 false면 a
2. ||
OR 연산
a || b
a가 true면 a, a가 false면 b
2. !
NOT 연산
!a
a를 true로 변환할 수 있으면 false를 반환. 그렇지 않으면 true를 반환
false 변환할 수 있는 표현의 예는 다음과 같습니다.
- null
- NaN
- 0
- 빈 문자열 ("", '', ``)
- undefined
연산자 우선순위
다음 표는 가장 높은 우선 순위 (21)에서 가장 낮은 우선 순위 (1)로 정렬되어 있습니다.
Precedence | Operator type | Associativity | Individual operators |
21 | Grouping | n/a | ( … ) |
20 | Member Access | left-to-right | … . … |
Computed Member Access | left-to-right | … [ … ] | |
new (with argument list) | n/a | new … ( … ) | |
Function Call | left-to-right | … ( … ) | |
Optional chaining | left-to-right | ?. | |
19 | new (without argument list) | right-to-left | new … |
18 | Postfix Increment | n/a | … ++ |
Postfix Decrement | … -- | ||
17 | Logical NOT (!) | right-to-left | ! … |
Bitwise NOT (~) | ~ … | ||
Unary plus (+) | + … | ||
Unary negation (-) | - … | ||
Prefix Increment | ++ … | ||
Prefix Decrement | -- … | ||
typeof | typeof … | ||
void | void … | ||
delete | delete … | ||
await | await … | ||
16 | Exponentiation (**) | right-to-left | … ** … |
15 | Multiplication (*) | left-to-right | … * … |
Division (/) | … / … | ||
Remainder (%) | … % … | ||
14 | Addition (+) | left-to-right | … + … |
Subtraction (-) | … - … | ||
13 | Bitwise Left Shift (<<) | left-to-right | … << … |
Bitwise Right Shift (>>) | … >> … | ||
Bitwise Unsigned Right Shift (>>>) | … >>> … | ||
12 | Less Than (<) | left-to-right | … < … |
Less Than Or Equal (<=) | … <= … | ||
Greater Than (>) | … > … | ||
Greater Than Or Equal (>=) | … >= … | ||
in | … in … | ||
instanceof | … instanceof … | ||
11 | Equality (==) | left-to-right | … == … |
Inequality (!=) | … != … | ||
Strict Equality (===) | … === … | ||
Strict Inequality (!==) | … !== … | ||
10 | Bitwise AND (&) | left-to-right | … & … |
9 | Bitwise XOR (^) | left-to-right | … ^ … |
8 | Bitwise OR (|) | left-to-right | … | … |
7 | Logical AND (&&) | left-to-right | … && … |
6 | Logical OR (||) | left-to-right | … || … |
5 | Nullish coalescing operator (??) | left-to-right | … ?? … |
4 | Conditional (ternary) operator | right-to-left | … ? … : … |
3 | Assignment | right-to-left | … = … |
… += … | |||
… -= … | |||
… **= … | |||
… *= … | |||
… /= … | |||
… %= … | |||
… <<= … | |||
… >>= … | |||
… >>>= … | |||
… &= … | |||
… ^= … | |||
… |= … | |||
… &&= … | |||
… ||= … | |||
… ??= … | |||
2 | yield | right-to-left | yield … |
yield* | yield* … | ||
1 | Comma / Sequence | left-to-right | … , … |
developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
Operator precedence - JavaScript | MDN
Operator precedence determines how operators are parsed concerning each other. Operators with higher precedence become the operands of operators with lower precedence. The source for this interactive example is stored in a GitHub repository. If you'd like
developer.mozilla.org
'Learning > Javascript' 카테고리의 다른 글
마우스 스크롤과 메뉴 하이라이트 주기 (0) | 2021.02.03 |
---|---|
호이스팅(hoisting) (0) | 2021.02.03 |
addEventListener 와 자주 사용하는 event (0) | 2021.01.10 |
함수 매개변수의 기본값 설정하기-삼항 연산자 , = === 사용 (0) | 2021.01.08 |
배열의 구조분해 - 선언 시 중괄호{}, 대괄호[] 사용 (0) | 2021.01.08 |