목록rest parameter (2)
코딩쌀롱
pr64061(doll_game).js (프로그래머스 64061문제 - 다른 풀이) 함수가 어떻게 실행되는지 이해하기 위해서 reduce, map 메서드, spread 연산자 학습. const transpose = matrix => matrix.reduce( (result, row) => row.map((_, i) => [...(result[i] || []), row[i]]), [] ); 📌 reduce() 두 번째 매개변수인 initialValue를 통해서 반환 값을 자유롭게 지정할 수 있다. (여러 자료형 가능) map, filter, find 함수로 구현할 수 있는 기능은 모두 reduce로도 가능하다. ✱ 매개변수 // initialValue는 optional arr.reduce(callback(..
prototype prototype은 말 그대로 객체의 원형. 함수는 객체 → 생성자도 객체 → 객체는 property를 가질 수 있고, prototype이라는 property를 가진다. (생성자 함수의 프로퍼티로 prototype을 갖는다) prototype에 저장된 속성들은 생성자를 통해서 객체가 만들어질 때 그 객체에 연결된다. function Ultra() {} Ultra.prototype.ultraProp = true; function Super() {} var t = new Ultra(); t.ultraProp = 4; Super.prototype = t; function Sub() {} Sub.prototype = new Super(); var o = new Sub(); console.log..