Lodash _.times Method Example

The _.times() executes the function n times.

Learn Lodash JS at Lodash JS Tutorial with Examples.

Lodash _.times Method Example

<!DOCTYPE html>
<html>
<head>
    <title>Lodash Tutorial</title>
    <script src="https://cdn.jsdelivr.net/npm/lodash@4.17.11/lodash.min.js"></script>

    <script type="text/javascript">
  _.times(4, () => {
   console.log("brave");
  })
    </script>
</head>
<body></body>
</html>
In the example, we execute the inner function four times. The function prints a word to the console.
brave
brave
brave
brave

Reference


Comments