toarray javascript
const collect = require('collect.js'); let arr = ['kripa', 'biltu', 'chinu', 1, 2, 3]; const collection = collect(arr); const newObject = collection.toArray(); console.log(newObject);
Here is what the above code is Doing:
1. We are importing the collect.js library.
2. We are creating an array.
3. We are creating a collection from the array.
4. We are converting the collection to an array.
5. We are printing the array.
Here’s the output:
[ ‘kripa’, ‘biltu’, ‘chinu’, 1, 2, 3 ]