๐๐ก๐๐ญ ๐๐ซ๐ ๐๐ข๐ ๐ก๐๐ซ ๐๐ซ๐๐๐ซ ๐
๐ฎ๐ง๐๐ญ๐ข๐จ๐ง๐ฌ ?
โ Normally when you hear the word functions you think of a regular function that takes an input, does some magic, and returns some value as output like this.
๐๐ฑ๐๐ฆ๐ฉ๐ฅ๐:
โ Normally when you hear the word functions you think of a regular function that takes an input, does some magic, and returns some value as output like this.
๐๐ฑ๐๐ฆ๐ฉ๐ฅ๐:
Now what's the difference between that normal function and a higher order function ?
โ A higher order function is a function that takes in a function as an argument or returns a function.
Examples:
โ ๐ฆ๐๐ฉ()
โ ๐๐จ๐ซ๐๐๐๐ก()
โ ๐ซ๐๐๐ฎ๐๐()
โ ๐๐ข๐ฅ๐ญ๐๐ซ()
โ A higher order function is a function that takes in a function as an argument or returns a function.
Examples:
โ ๐ฆ๐๐ฉ()
โ ๐๐จ๐ซ๐๐๐๐ก()
โ ๐ซ๐๐๐ฎ๐๐()
โ ๐๐ข๐ฅ๐ญ๐๐ซ()
โ Now all these higher order functions apply to arrays so we'll make a dummy array with some numbers to practice using those functions.
nums = [2,4,6,8,3,5]
nums = [2,4,6,8,3,5]
๐: ๐๐๐ ๐๐๐() ๐๐๐๐๐๐
โ This method iterates over an array and takes in one parameter that represents the element in the current iteration.
โ This method iterates over an array and takes in one parameter that represents the element in the current iteration.
โ You don't need to say return as the function returns a value by default.
๐: ๐๐๐ ๐๐๐๐๐๐ ๐๐๐๐๐๐
โ This method takes a callback that takes two parameters, one that represents the element from the last iteration and the other is the current element of the iteration.
โ This method takes a callback that takes two parameters, one that represents the element from the last iteration and the other is the current element of the iteration.
4: ๐๐๐ ๐
๐๐๐๐๐() ๐๐๐๐๐๐
โ We use this method to filter out desired elements as per a condition we specify.
โ let say you only want the odd numbers or even numbers or want numbers higher or lower than a specific value,
โ We use this method to filter out desired elements as per a condition we specify.
โ let say you only want the odd numbers or even numbers or want numbers higher or lower than a specific value,
End of this thread๐งต
I hope this thread was helpful to you. Please consider:
๐ Liking these tweets.
๐ Retweeting the first tweet so other people can see it.
๐ค Following me ( @Div_pradeep) for more content.
Thanks for reading.
I hope this thread was helpful to you. Please consider:
๐ Liking these tweets.
๐ Retweeting the first tweet so other people can see it.
๐ค Following me ( @Div_pradeep) for more content.
Thanks for reading.
Loading suggestions...