How to use third-party library In Javascript
The _.range() method is used to create an array of numbers progressing from the given start value up to, but not including the end value.
For installing `lodash`, run the following command
npm init -y
npm install lodash
Example: In this example, we are third-party library.
// Requiring the lodash library
const _ = require("lodash");
// Using the _.range() method
let range_arr = _.range(1,5);
// Printing the output
console.log(range_arr);
Output:
[ 1, 2, 3, 4 ]
How to create an array containing 1…N numbers in JavaScript ?
In this article, we will see how to create an array containing 1. . . N numbers using JavaScript. We can create an array by using different methods.
There are some methods to create an array containing 1…N numbers, which are given below:
Table of Content
- Using for Loop
- Using Spread Operator
- Using from() Method
- Using third-party library
- Using a Generator Function