반응형
let result = 2 * 3 + 4; // the result is 10 (2 * 3 = 6, 6 + 4 = 10)
let result2 = 2 + 4 / 2; // the result is 3 (4 / 2 = 2, 2 + 2 = 3)
`*` , `/` 가 `+` 보다 우선
let result = (2 + 3) * 4; // the result is 20 (2 + 3 = 5, 5 * 4 = 20)
()괄호 안이 우선
let result = 2 * 3 / 2; // the result is 3 (2 * 3 = 6, 6 / 2 = 3)
`*` `/` 는 우선순위가 동일하며 이때는 왼쪽에서 오른쪽으로
반응형
'Javascript' 카테고리의 다른 글
날짜 객체 new Date() (0) | 2023.01.24 |
---|---|
form selector 유효성점검 submit (0) | 2023.01.24 |
에러 처리 & 디버깅 (0) | 2023.01.24 |
Arrow function 화살표함수 (0) | 2023.01.24 |
Class 클래스 (0) | 2023.01.24 |
댓글