콜백함수

    [mdn, 드림코딩, 코딩애플] 콜백함수 (1) : 동기와 비동기 개념

    콜백함수 자바스크립트는 동기적(synchronous) 언어이다. 이 말은 코드를 작성한 순서에 맞춰 동기적으로 실행된다는 말이다. 아래는 비동기적으로 실행되는 함수이다. console.log('1'); setTimeout(() => console.log('2'), 1000); console.log('3'); //1 //3 //2 Synchronous callback function printImmediately(print) { print(); } printImmediately(() => console.log('hello')); Asynchronous callback function printWithdelay(print, timeout) { setTimeout(print, timeout); } printW..

    [드림코딩 외] 콜백함수 (Callback function)

    콜백함수 (Callback function) 콜백함수는 어떤 이벤트가 발생했거나 특정 시점에 도달했을 때 시스템에서 호출하는 함수를 말한다. (특별한 선언법이나 다른 문법을 가진 함수가 아닌, 호출하는 방식에 따라 구분된 함수이다.) function whatCoder(codingTest, goodCode, badCode) { if(codingtest === 'Callback function') { goodCode(); } else { badCode(); } } const goodCode = function () { console.log('Great!') }; const badCode = function () { console.log('Do it again.') }; whatCoder(`I don't kn..