`_.range` function on array using JavaScript Library underscore.js ( #shorts )

1 year ago
8

Hi Friends,

`_.range` function on array using JavaScript Library underscore.js

`_.range` is a utility function in Underscore.js library that allows you to generate a sequence of numbers in a specified range.

In below example, we use _.range to generate a sequence of numbers starting from 1, up to, but not including 10, with a step of 2. The resulting numbers array contains the numbers [1, 3, 5, 7, 9].

Note: _.range returns a new array containing the generated sequence of numbers from the start value up to, but not including, the stop value, incrementing by the step value.

// syntax
_.range([start], stop, [step])

//example
var numbers = _.range(1, 10, 2);
console.log(numbers);
// [1, 3, 5, 7, 9]
var numbers = _.range(5, 0, -1);
console.log(numbers);
// [5, 4, 3, 2, 1]
var numbers = _.range(5);
console.log(numbers);
// [0, 1, 2, 3, 4]

#javascript #under #score #underscore #underscorejs #underscorerange #rangefunction #range #object #array #string #nodejs #javascriptinterview #method #js #jquery #function #shorts #viral #popular #latest #new #coders #development #code #dev #interview #php #trend #trending #answer #best #free #laravel #youtube #instagram #socialmedia #education #edit #how #india #knowledge #quiz #reels #short #subscribe #share #update #video #web #webdeveloper #website #webdesign #ytshorts #youtuber #princecheema_official @princecheema_official

Loading comments...