Jacob Ruiz

View Original

How to Limit The Number Of Times A Function Can Be Called in Javascript

Imagine we define a function that returns the time:

See this content in the original post

Calling this function will always give us the present time (expressed in the number of milliseconds elapsed since January 1, 1970).

See this content in the original post

With Underscore's before function we can create a new version of this function that is can only be called a certain number of times.

See this content in the original post