Skip to content

Instantly share code, notes, and snippets.

View khg0712's full-sized avatar
👶
Baby Developer

Hugo Kim khg0712

👶
Baby Developer
View GitHub Profile
var cat = new Object();//Object() 생성자 함수를 통한 cat 객체 생성
cat.name = 'James';//cat객체의 프로퍼티 설정
cat.age = 2;
cat.leg = 4;
var a = "a"; //a는 이제 string 타입
a = 1; //a는 이제 number 타입
a = true; //a는 이제 boolean 타입
a = null //a는 이제 null 타입
a = undefined //a는 이제 undefined 타입
-0 === 0 // true
1 / 0 //Infinity
1 / -0 //-Infinity
Symbol('a') == Symbol('a') //결과: false
//각 심볼이 고유의 값을 가지고 있어 서로 다름
Symbol('a') == Symbol.for('a') // 결과: false
Symbol.for('a') == Symbol.for('a') //결과: true
//전역 레지스트리에서 같은 키의 심볼은 공유하므로 서로 같다.
var a = "abc"; a[1] = "d";
console.log(a); // 출력: "abc" // 변경 불가!
var cat = {
name: 'James',
age: 2,
leg: 4
};//객체 리터럴 방식으로 객체
@khg0712
khg0712 / JS-object-type-Example4.js
Last active May 2, 2018 08:24
대괄호 표기법 오류 예시
var a = {
undefined: 'k',
b: 'z',
c: 'a'
j: 'j'
};
var b;
var c = 'j';
var a = {
column: 3,
row: 2
};
//프로퍼티 접근
console.log(a.column);//3 출력
console.log(a['row']);//2 출력
console.log(a.span);//undefined 출력
@khg0712
khg0712 / JS-object-type-Example5.js
Last active May 2, 2018 14:55
객체 delete 연산자 사용법 예시
var a = {
name: 'Hello',
age: 2
};
delete a.name;
console.log(a.name);//undefined 출력
delete a['age'];
console.log(a['age']);//undefined 출력
@khg0712
khg0712 / JS-object-type-Example6.js
Created May 3, 2018 13:36
생성자 함수 예시
function a(){
this.a = 1;
this.b = 2;
}//함수 리터럴로 생성자 함수 생성
var b = new a();//생성자를 통한 객체 생성
console.log(b.a);//1 출력