Lodash _.range Method Example

The Lodash _.range() function creates an array of numbers. The function accepts the start, end, and step parameters.

Learn Lodash JS at Lodash JS Tutorial with Examples.

Lodash _.range 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">
  const vals = _.range(10);
  console.log(vals);

  const vals2 = _.range(0, 15);
  console.log(vals2);

  const vals3 = _.range(0, 15, 5);
  console.log(vals3);
    </script>
</head>
<body></body>
</html>
Output:
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 ]
[ 0, 5, 10 ]

Reference



Comments