Skip to main content

Lodash

What is lodash?

Lodash is a JavaScript library that works on the top of underscore.js. It helps in working with arrays, strings, objects, numbers, etc

install lodash

% npm i lodash
  • import into any component or file
import _ from 'lodash';

range

  • Creates an array of numbers (positive and/or negative) progressing from start up to, but not including, end.
_.range(4); // => [0, 1, 2, 3]
_.range(-4); // => [0, -1, -2, -3]
_.range(1, 5); // => [1, 2, 3, 4]
_.range(0, 20, 5); // => [0, 5, 10, 15]
_.range(0, -4, -1); // => [0, -1, -2, -3]
_.range(1, 4, 0); // => [1, 1, 1]
_.range(0); // => []