VOOZH about

URL: https://www.geeksforgeeks.org/javascript/collect-js-push-function/

⇱ Collect.js | push() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Collect.js | push() Function

Last Updated : 12 Jun, 2020

The push() function is used to add a new value to the end of the collection.  In JavaScript, the array is first converted to a collection and then the function is applied to the collection.
Syntax: 

data.push(value)


Parameters: This function accepts a single parameter as mentioned above and described below:

  • value: This parameter holds the value to be added.

Return Value: Returns a modified collection which is created by this function.


Below examples illustrate the push() function in collect.js
Example 1:

Output: 

[ 'Geeks', 'for', 'Geeks', 'CS' ]

Example 2:

Output: 

[ 10, 20, 30, 40 ]

Reference: https://collect.js.org/api/push.html

Comment
Article Tags: