React Currting

Yeeeeeun_IT·2022년 8월 26일
0

React Currting

Currying

커링(Currying)은 인자가 여러개인 함수의 일부 인자를 고정시키는 새로운 함수를 만드는 기법이다.

function helloFunc(word, name) {
    console.log(`${word}, ${name}`);
}
function helloFunc(word) {
    return function (name) {
        console.log(`${word}, ${name}`);
    };
}

const printHello = helloFunc("hello"); 
printHello("apple"); // hello, apple
printHello("mango");       // hello, mango

즉 커링 기법은 일부 인자에 같은 값을 반복적으로 사용할 때 그 반복되는 인자를 고정함으로써 중복을 최소화 하기에 적합한 기법이다.

참조 : https://tibetsandfox.tistory.com/32

profile
🍎 The journey is the reward.

0개의 댓글