TIL22 - JS - Higher Order Functions

Peter D Lee·2020년 8월 31일
0

JavaScript

목록 보기
11/19

Higher-order fuctions are functions that take in other functions as parameters, return a function as an output, or both

  • In JavaScript, functions are obects
  • Functions are first class objects, meaning they have properties and methods like any other objects
  • Functions work like any other data types, meaning they can be reassigned to other variables and taken as parameters/arguments in other functions
  • When a function is used as an argument to a higher-order function, the function is called a callback function -> the function is not 'called' or 'invoked' to return the output of the function call, but is 'called back' to refer to the function itself by the higher-order function.
    > when using callback functions, you write only the function's name without (). The () used with the function name is for function calls.
    > this also applies when you assign a function to a new variable -> you are not assigning the result of the function call to the new variable. you are assigning the function itself to the new variable for an easier callback later on

0개의 댓글