Underscore.js _.iteratee() Function (original) (raw)
Last Updated : 24 Nov, 2021
Underscore.js is a JavaScript library that provides a lot of useful functions that help in the programming in a big way like the map, filter, invoke, etc. even without using any built-in objects.
The _.iteratee() function is an inbuilt function in Underscore which is used to generate a callback that can be applied to every element in a collection. This method supports multiple shorthand syntaxes for common callback use cases and returns the output depending on the type of the value.
Syntax:
_.iteratee( value, context )
Parameters: This method accepts two parameters as mentioned above and described below:
- value: It is the stated value.
- context: It is the context to be used. It is an optional parameter.
Return Value: This method returns the output depending on the type of value.
Example 1: In this example, no parameter is used with the method.
HTML `