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 asfirst-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 ofHigher-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,filterandreduce. Higher Order FunctionsinJavascriptenable us to use a function as a parameter to another function.- The
useFunction()function accepts afunction_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 examplelogger()in Javascript. - The returnFunction() function is a higher-order function
outputtingthesecondFunction()that requires an additional parametery. - You can write functions that accept other functions as parameters, as well as
returnthem asoutputs. - 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 overactions as well as values. - The output of the code is A due to the use of the higher-order function,
filterArr, with a loop topushelements greater thanminto a new array, which is then logged asElements that are greater than m = 9 are: 10,25. - A
higher-order functionfilterArr()generates and returns thegreaterThan()function, which filters elements of an array larger than its inputm. - Using a higher-order function to
transformafunctionis 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, returning1when called with[ 3, 10, 25, 1, 7 ]. Using a higher-order functioncancreatea new control flow.- The provided code uses a custom
forEachloop and anunlessfunction to check if each element in theintArrarray is even or odd, yielding10 is even 2 is evenas 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(), andforEach(), 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.


