산술 연산자
+ 더하기
- 빼기
* 곱하기
% 나누기
++ 1씩 증가 =
-- 1씩 감소
비교 연산자
<
>
<=
>=
== (값만 같으면 true)
!=
=== (값도 같고, 타입도 같아야 true, 두개짜리보다 이걸 사용하는걸 더 권장함)
!==
대입 연산자
=
+=
-=
*=
%=
/=
논리 연산자
!
&&
||
삼항 연산자
조건식 ? 실행문1 : 실행문2
자바랑 연산자가 다 같지만 ===, !== 이 부분만 다르다.
var num1 = "10";
var num2 = 10;
console.log(num1 == num2); //true (값만 비교)
console.log(num1 != num2); //false
console.log(num1 === num2);//false (값과 타입까지 비교)
console.log(num1 !== num2);//true
var a;
var b = null;
//변수값 동시에 출력 ,
console.log(a,b, a==b); //undefined null true(둘다 값이 없기때문에 true)
console.log(a,b, a!=b); //undefined null false
console.log(a,b, a===b); //undefined null false(값은 같지만 타입이 다르기에 false)
console.log(a,b, a!==b); //undefined null ture
'JavaScript' 카테고리의 다른 글
JS | 함수(즉시실행 함수) (0) | 2022.12.28 |
---|---|
JS | 함수(선언적 함수/익명 함수) (0) | 2022.12.28 |
JS | 조건문 (0) | 2022.12.28 |
JS | 배열 (0) | 2022.12.28 |
JS | 출력, 확인 / 변수, 데이터 타입 (1) | 2022.12.27 |