Skip to content

Instantly share code, notes, and snippets.

View QuatoHub's full-sized avatar
🎯
Focusing

Hyeonjun Moon QuatoHub

🎯
Focusing
View GitHub Profile
@QuatoHub
QuatoHub / Quato.js
Last active September 11, 2021 09:06
// 심벌 값 생성
let key = Symbol("key");
console.log(typeof keey); // symbol
// 객체 생성
let obj = {};
// 이름이 충돌할 위험이 없는 유일무이한 값이 심벌의 프로퍼티 키로 사용
obj[key] = "value";
console.log(obj[key]); // value
5 + 2; // 7
5 - 2; // 3
5 * 2; // 10
5 / 2; // 2.5
5 % 2; // 1
// ++ 연산자는 피연산자의 값을 변경하는 암묵적 할당이 이뤄진다.
x++; // x = x + 1;
console.log(x); // 2
// -- 연산자는 피연산자의 값을 변경하는 암묵적 할당이 이뤄진다.
x--; // x = x - 1;
console.log(x); // 1
@QuatoHub
QuatoHub / Quato.js
Last active September 11, 2021 09:06
let x = 5,
result;
// 선할당 후증가(postfix increment operatior)
result = x++;
console.log(result, x); // 5 6
// 선증가 후할당(prefix increment operatior)
result = ++x;
console.log(result, x); // 7 7
@QuatoHub
QuatoHub / Quato.js
Last active September 11, 2021 09:06
let x = "1";
// 문자열을 숫자로 타입 변환한다.
console.log(+x); // 1
// 부수 효과는 없다.
console.log(x); // "1"
// 불리언 값을 숫자로 타입 변환한다.
x = true;
console.log(+x); // 1
@QuatoHub
QuatoHub / Quato.js
Last active September 21, 2021 13:20
// 문자열 연결 연산자
"1" + 2; // '12'
1 + "2"; // '12'
@QuatoHub
QuatoHub / Quato.js
Last active September 11, 2021 09:06
let x;
// 할당문은 표현식인 문이다.
console.log((x = 10)); // 10
// 동등 비교
5 == 5; // true
// 타입은 다르지만 암묵적 타입 변환을 통해 타입을 일치시키면 동등하다.
5 == "5"; // true
// 일치 비교
5 === 5; // true
// 암묵적 타입 변환을 하지 않고 값을 비교한다.
// 즉, 값과 타입이 모두 같은 경우만 true를 반환한다..
5 === "5"; // false
// NaN은 자신과 일치하지 않는 유일한 값
NaN ==== NaN; // false