Coding / Programming Videos

Post your favorite coding videos and share them with others!

[JavaScript] First-class Function 一級函式 – Aaron Lu – Medium

Source link


Passing a function as an argument

function sayHi() {
return "Hi,";
function greeting(hiMessage, name) {
console.log(`${hiMessage()} ${name}!`);
// Pass `sayHi` as an argument to `greeting` function
greeting(sayHi, "Tom");

被當作參數傳遞的那個函式稱之為回調函式 Callback function 
sayHi 就是一個回調函式。

Source link


Leave a Reply

Please Login to comment
Notify of
Translate »