[TIL]

Dev_minยท2019๋…„ 10์›” 1์ผ
0

TIL

๋ชฉ๋ก ๋ณด๊ธฐ
7/61

๐Ÿ‘‰Toy - commonCharacter

Error --> Extra Credit: should return common characters between more than two strings

๐Ÿ‘‰Destructuring assignment

({a, b, ...rest} = {a: 10, b: 20, c: 30, d: 40}); 
console.log(a); // 10 
console.log(b); // 20 
console.log(rest); // {c: 30, d: 40}
{...}

var x = [1, 2, 3, 4, 5]; 
var [y, z] = x; 
console.log(y); // 1 
console.log(z); // 2
 
// ๋ณ€์ˆ˜์— ๊ธฐ๋ณธ๊ฐ’์„ ํ• ๋‹นํ•˜๋ฉด, ๋ถ„ํ•ดํ•œ ๊ฐ’์ด undefined์ผ ๋•Œ ๊ทธ ๊ฐ’์„ ๋Œ€์‹  ์‚ฌ์šฉ
var a, b; 
[a=5, b=7] = [1];
console.log(a); // 1 
console.log(b); // 7

๐Ÿ‘‰spread syntax

function sum(x, y, z) {
  return x + y + z;
}

const numbers = [1, 2, 3];

console.log(sum(...numbers));
// expected output: 6

console.log(sum.apply(null, numbers));
// expected output: 6


// ๋ฐฐ์—ด์„ ์—ฐ๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•
var arr1 = [0, 1, 2]; 
var arr2 = [3, 4, 5]; // arr2 ์˜ ๋ชจ๋“  ํ•ญ๋ชฉ์„ arr1 ์— ๋ถ™์ž„ 
arr1 = arr1.concat(arr2);

// ์ „๊ฐœ๊ตฌ๋ฌธ ์‚ฌ์šฉ
var arr1 = [0, 1, 2]; 
var arr2 = [3, 4, 5]; 
arr1 = [...arr1, ...arr2]; // arr1 ์€ ์ด์ œ [0, 1, 2, 3, 4, 5]
profile
TIL record

0๊ฐœ์˜ ๋Œ“๊ธ€