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

Bookmark(0)
 

Leave a Reply

Please Login to comment
  Subscribe  
Notify of
Translate »