목록js 함수 (1)
dev_eun
[JS] 함수
First-class Function 함수가 변수처럼 취급된다. 변수에 할당할 수 있다. 매개변수를 전달받을 수 있다. 리턴값을 리턴할 수 있다. anonymous function 이름이 없는 함수 const print = function() { console.log('print'); }; callback function 매개변수로 함수를 전달한다. 클라이언트에게 구현을 맡기는 것과 같음 function randomQuiz(answer, printYes, printNo) { if(answer === 'love you') { printYes(); } else { printNo(); } }; const printYes = function() { console.log('Yes!'); } const printN..
Web/vanilla js
2021. 6. 28. 03:21