This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.prototype.obj = function () {}; | |
Array.prototype.arr = function () {}; | |
var iterable = [3, 5, 7]; | |
iterable.f = "hello"; | |
for (var key in iterable) { | |
console.log(key); // 0, 1, 2, "f", "arr", "obj" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const obj = { a: 1, b: 2, c: 3 }; | |
Object.prototype.obj2 = function() { | |
return 0; | |
} | |
for (const key in obj) { | |
console.log(key, obj[key]); | |
} // a 1 b 2 c 3 obj function()... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arr = [1, 2, 3, 4, 5]; | |
arr.forEach(item => console.log(item); ); // 1, 2, 3, 4, 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES5 | |
var array = ["apple", "banana", "pineapple"]; | |
for (var i = 0; i < array.length; i++) { | |
console.log(array[i]); | |
} | |
var string = 'hello world'; | |
for (var i = 0; i < string.length; i++) { | |
console.log(string[i]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES5 | |
var double = function(num) { | |
return num * 2; | |
} | |
// ES6 | |
let double = num => num * 2; | |
// 화살표 함수에서의 this | |
console.log(this === window); // true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES5 | |
let iAm = function(name, age, country) { | |
return name + ',' + age + ',' + country; | |
} | |
// ES6 | |
let iAm = function(name, age, country = 'South Korea') { | |
return `${name}, ${age}, ${country}`; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES5 | |
let iAm = function(name, age, country) { | |
country = country === undefined? 'South Korea' : country; | |
} | |
console.log(iAm('ryn', 20)); // 'ryn', 20, 'South Korea' | |
console.log(iAm('ryn', 20, 'Canada')); // 'ryn', 20, 'Canada' | |
// ES6 | |
let iAm = function(name, age, country = 'South Korea') { | |
country = country === undefined? 'South Korea' : country; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let array = ["apple", "banana", "pineapple"]; | |
let newArr = [...array]; | |
console.log( newaArr === array ); // false, 원본 배열을 바꾸지 않음 | |
// Spread Operator 활용 | |
function sum(a, b, c){ | |
return a + b + c; | |
} | |
let array = [100, 200, 300]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Array | |
// ES5 | |
var array = [1, 2, 3]; | |
var apple = array[0]; // 1 | |
var banana = array[1]; // 2 | |
// ES6 | |
var array = [1, 2, 3]; | |
var [apple, banana] = array; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node { | |
constructor(value) { | |
this.value = value; // 데이터 값 | |
this.next = null; // 다음 노드 | |
} | |
} | |
class LinkedList { | |
constructor() { | |
this.head = null; // 시작노드 |
NewerOlder