// 1. 더하기 연산자
console.log(1 + 1); // 2
console.log(1 + "1"); // 11
// 문자열로 변환되어 2가 아니라 "1"+"1" => 11 출력됨
// 2. 빼기 연산자
console.log(1 - "2"); // -1
console.log(1 - 2); // -1
// 3. 곱하기 연산자 (*)
console.log(2 * 3); // 6
console.log("2" * 3); // 6
// 4. 나누기 연산자(/) vs 나머지 연산자(%)
console.log(5 / 2); // 2.5
console.log("4" / 2); // 2
console.log(5 % 2); // 1
// 5. 할당 연산자(assignment)
// 5-1. 등호 연산자(=)
let x = 10;
console.log(x)
// 5-2. 더하기 등호 연산자(+=)
x += 5; // x = x + 5
console.log(x);
// 5-3. 빼기 등호 연산자(-=)
x -= 5; // x = x - 5
console.log(x)
간단히 하면 사칙연산과 나머지이다
'오늘 뭐했냐 > 개발에 대한 주저리' 카테고리의 다른 글
논리 연산자 (0) | 2023.05.22 |
---|---|
비교 연산자 (0) | 2023.05.22 |
형 변환 (0) | 2023.05.22 |
데이터 타입(객체타입) (0) | 2023.05.22 |
데이터 타입(원시타입) (0) | 2023.05.22 |