You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
552 B

4 years ago
  1. # `toArray()`
  2. The toArray method converts the collection into a plain array.
  3. If the collection is an object, an array containing the values will be returned.
  4. ```js
  5. const collection = collect([1, 2, 3, 'b', 'c']);
  6. collection.toArray();
  7. // [1, 2, 3, 'b', 'c']
  8. ```
  9. ```js
  10. const collection = collect({
  11. name: 'Elon Musk',
  12. companies: ['Tesla', 'Space X', 'SolarCity'],
  13. });
  14. collection.toArray();
  15. // ['Elon Musk', ['Tesla', 'Space X', 'SolarCity']]
  16. ```
  17. [View source on GitHub](https://github.com/ecrmnn/collect.js/blob/master/src/methods/toArray.js)