Mark As Completed Discussion

One Pager Cheat Sheet

  • JavaScript is a function-based programming language that enables developers to use higher-order functions for abstraction and reducing code repetition.
  • JavaScript supports functional programming, which allows us to utilise pure mathematical functions and treat functions as first-class citizens.
  • JavaScript allows functions to be used as first-class citizens, meaning they can be assigned to variables, used as object attributes, stored in arrays and utilized as function arguments or returns, which allows for the development and use of Higher-order functions.
  • Functions in JavaScript, which are considered as first-class citizens, allows us to use higher-order functions to compose new Array transformations through map, filter and reduce.
  • Higher Order Functions in Javascript enable us to use a function as a parameter to another function.
  • The useFunction() function accepts a function_as_argument() as a parameter, allowing it to manipulate array items.
  • Functions can return other functions, which allows us to create Higher Order Functions, as shown in the example logger() in Javascript.
  • The returnFunction() function is a higher-order function outputting the secondFunction() that requires an additional parameter y.
  • You can write functions that accept other functions as parameters, as well as return them as outputs.
  • The higher-order function, useReturnFunc(), returns a function, secondFunction(), which takes an argument as a string, when given a function, fn(), as an input.
  • Higher-order functions can be used to abstract over actions as well as values.
  • The output of the code is A due to the use of the higher-order function, filterArr, with a loop to push elements greater than m into a new array, which is then logged as Elements that are greater than m = 9 are: 10,25.
  • A higher-order function filterArr() generates and returns the greaterThan() function, which filters elements of an array larger than its input m.
  • Using a higher-order function to transform a function is an example of Functional Programming.
  • The changeFn() higher-order function accepts a function as an argument and passes all of the required arguments to it, returning 1 when called with [ 3, 10, 25, 1, 7 ].
  • Using a higher-order function can create a new control flow.
  • The provided code uses a custom forEach loop and an unless function to check if each element in the intArr array is even or odd, yielding 10 is even 2 is even as the output.
  • The unless() higher-order function enables users to create custom control flow based on a test condition.
  • JavaScript has numerous built-in higher-order functions, including map(), reduce(), addEventListener(), filter(), and forEach(), that offer substantial abstraction.
  • The Array.prototype.filter() method creates a filtered shallow duplicate of the array that contains only elements that pass a specific test.
  • Higher-order functions in JavaScript are powerful tools that allow for code to be communicated through actions and improved reusability, while providing the flexibility to use built-in or customized functions to handle complex tasks.