Created
April 5, 2018 09:18
-
-
Save indongyoo/eab207950ea45f22cb632be43ddf58a1 to your computer and use it in GitHub Desktop.
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 p1 = { | |
id: 1, | |
selected: true, | |
name: 'A 반팔티', | |
price: 12000, | |
discount: 2000, | |
quantity: 3 | |
}; | |
// map에 함수를 하나만 전달하여 자동 부분 적용 | |
const gets = map(key => a => a[key]); | |
// gets 함수를 통해 객체의 key에 할당된 값을 얻어오는 함수들 생성 | |
const [price, discount, quantity, selected] = | |
gets(['price', 'discount', 'quantity', 'selected']); | |
console.log( price(p1) ); // 12000 | |
console.log( discount(p1) ); // 2000 | |
console.log( quantity(p1) ); // 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment