Underscore.js _.before() Function (original) (raw)
Last Updated : 20 Dec, 2022
_.before() function in underscore.js is used to call a particular function a particular number of times. It uses a count variable that keeps the track of number of times the function is called.
Syntax:
_.before(count, function)
Parameters:
- Count: It is the number of times a function is to be called.
- Function: It is the function that runs the count times.
Return: This function returns the count of the function call.
Note: Please Link the underscore CDN before using this code directly in the browser through the code.
Example 1:
html ``
``
Output:
Example 2:
It is clear from the example that if The button is clicked again and again then print function will not be working as it as already reached the count.
html ``
button``
Output:
Similar Reads
- Underscore.js What is Underscore.js? Underscore.js is a lightweight JavaScript library and not a complete framework that was written by Jeremy Ashkenas. It provides utility functions for a variety of use cases in our day-to-day common programming tasks. Underscore.js provides a lot of features that make our task 4 min read
- Underscore.js Introduction Underscore.js is a lightweight JavaScript library and not a complete framework that was written by Jeremy Ashkenas that provides utility functions for a variety of use cases in our day to day common programming tasks. With just under six kilobytes in size, this library basically provides us with a w 2 min read