Skip to content

Instantly share code, notes, and snippets.

View khg0712's full-sized avatar
🎯
Focusing

Hugo Kim khg0712

🎯
Focusing
View GitHub Profile
@khg0712
khg0712 / JS-array-type-Example2.js
Created May 12, 2018 14:25
배열 생성 예제 2
var a = [1,2,3,,4];//[1,2,3,empty,4] 배열 생성
var b = [1,2,3,,,4];//[1,2,3,empty,empty,4] 배열 생성
var c = [1,2,3,4,,];//[1,2,3,4,empty] 배열 생성
@khg0712
khg0712 / JS-array-type-Example1.js
Last active May 12, 2018 14:18
배열 생성 및 접근 예시
//Array 생성자로 배열 생성
var a = new Array(1);//생성자의 인자가 하나일 땐 해당 인자가 배열의 크기가 된다.
var b = new Array(1,2,3,4);//생성자의 인자가 여러 개일 땐 인자들이 배열의 요소가 된다.
//배열 리터럴로 배열 생성
var c = [1,2,3];
console.log(a[0],a[1]);//undefined, undefined 출력
console.log(b[0],b[1]);//1 2 출력
console.log(c[0],c[1]);//1 2 출력
@khg0712
khg0712 / JS-object-type-Example7.js
Created May 3, 2018 13:45
객체와 프로토타입 관계 예시
var cat = {
name: 'James',
age: 2
};//cat 객체 생성
console.log(cat.toString());//[object Object] 출력
console.dir(cat);
@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 출력
@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 출력
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-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 cat = {
name: 'James',
age: 2,
leg: 4
};//객체 리터럴 방식으로 객체
var a = "abc"; a[1] = "d";
console.log(a); // 출력: "abc" // 변경 불가!
Symbol('a') == Symbol('a') //결과: false
//각 심볼이 고유의 값을 가지고 있어 서로 다름
Symbol('a') == Symbol.for('a') // 결과: false
Symbol.for('a') == Symbol.for('a') //결과: true
//전역 레지스트리에서 같은 키의 심볼은 공유하므로 서로 같다.