TIL 2020.11.09

First-class citizen(일급 객체)

  1. can assign into variable
  2. can refer to argument(인자) of other function
  3. can return as the result of other function
  • ex. function

function expression(함수 표현식)

  • can not use before assignment(할당)
  • hoisting is not happening unlike ‘function declaration’(함수 선언식)

Higher order function(고차 함수)

함수 = 값을 전달 받아 값을 리턴한다 = 값에 대한 복잡한 로직은 감추어져 있다 = 값 수준에서의 추상화

값 수준의 추상화: 단순히 값(value)을 전달 받아 처리하는 수준

사고의 추상화: 함수(사고의 묶음)를 전달 받아 처리하는 수준

고차함수 = 함수를 전달 받거나 함수를 리턴한다 = 사고(함수)에 대한 복잡한 로직은 감추어져 있다 = 사고 수준에서의 추상화

  • a function that takes as a argument or returns a function
  • Callback function
  • a function passed into caller(another function) as an argument, which is then invoked(호출)
  • depends on caller’s condition, can decide callback function to be executed or executed even several times
  • mostly invoked when certain work is done so called as callback

Curry function

  • specifically for a function that returns function
  • part of higher order function
  1. When it takes caller(other function) as an argument

2. When it returns function

3. When it takes function as argument and returns function

Built-in higher order functions(내장 고차 함수)

Array.prototype.filter() 분류해서 거르기!!

  • filter out with elements that satisfy certain condition from array
  • condition has to be delivered in function form as an argument of filter method
  • part of higher order function since function takes as an argument
  • returns back as an ‘ARRAY’ to callback function that takes argument
  • ‘CALLBACK’ function will return a Boolean value
  • If result is ‘TRUE’, it will create an array with that element, if not, NO

Array.prototype.map() 대응, 갯수를 맞춰줘야 됨 배열자체의 수정용!!

  • creates a ‘NEW ARRAY’ populated with result of calling a provided function on every element in the calling array
  • can extract values from list of objects

Array.protoype.reduce() 변환이 되어 응축, 연산용!!

  • executes a reducer function(that you provide) on each element of the array, resulting in ‘SINGLE OUTPUT VALUE’
  • can make various type
  • arr.reduce(callback[, initialValue])
  • 초기값 설정 중요!
  • if they want empty array, put [] like this
  • if there is initial value, it becomes first value to calculate(A value to use as the first argument to the first call of the callback. If no initialValue is supplied, the first element in the array will be used as the initial accumulator value and skipped as currentValue.)
  • use when you want to merge arrays by using concat
  • reduce는 초기값을 두 번째 인자로 설정했을 때 빈 배열이 오는 경우 초기값을 그대로 리턴하는 자체적인 특성이 있는 것으로 보입니다.


  • sorts the elements of an array in place and returns the ‘SORTED ARRAY’
  • default sort order is ascending, built upon converting elements into string then comparing their sequences of UTF-16 code units values


  • tests whether ‘AT LEAST ONE ELEMENT’ in the array ‘PASSES’ the test implemented by the provided function
  • returns a Boolean Value


  • tests whether ‘ALL ELEMENTS’ in the array ‘PASS’ the test implemented by the provided function
  • returns a Boolean value


  • executes a provided function ‘ONCE FOR EACH ARRAY ELEMENT’


  • returns the value of the ‘FIRST ELEMENT’ in the provided array that satisfies the provided testing function



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store