Node.js push() function Last Updated : 08 Jan, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report push() is an array function from Node.js that is used to add elements to the end of an array. Syntax:array_name.push(element)Parameter: This function takes a parameter that has to be added to the array. It can take multiple elements also. Return type: The function returns the array after adding the element. The program below demonstrates the working of the function: Program 1: javascript function PUSH() { arr.push(2); console.log(arr); } const arr = [12, 3, 4, 6, 7, 11]; PUSH(); Output:[ 12, 3, 4, 6, 7, 11, 2]Program 2: javascript function addLang() { arr.push('DS', 'Algo', 'JavaScript'); console.log(arr); } const arr = ['NodeJs']; addLang(); Output:[ 'NodeJs', 'DS', 'Algo', 'JavaScript' ]Program 3: javascript const Lang = ['java', 'c', 'python']; console.log(Lang); // expected output: Array [ 'java', 'c', 'python' ] Lang.push('node'); console.log(Lang); // expected output: Array [ 'java', 'c', 'python', 'node' ] Output:[ 'java', 'c', 'python' ][ 'java', 'c', 'python', 'node' ] Comment More infoAdvertise with us Next Article Collect.js | push() Function T Twinkl Bajaj Follow Improve Article Tags : Web Technologies Node.js NodeJS-function Similar Reads Node.js unshift() function unshift() is an array function from Node.js that is used to insert elements to the front of an array. Syntax: array_name.unshift(element) Parameter: This function takes a parameter that has to be added to the array. It can take multiple elements also as parameters. Return type: The function returns 1 min read Node.js pop() function pop() is an array function from Node.js that is used to remove elements from the end of an array. Syntax: array_name.pop() Parameter: This function does not take any parameter. Return type: The function returns the array. The program below demonstrates the working of the function: Example 1: javascr 1 min read Collect.js | push() Function 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 describe 1 min read Types of API functions in Node.js Node.js, known for its asynchronous and event-driven architecture, is a popular choice for building scalable server-side applications. One of its primary uses is to create and manage APIs (Application Programming Interfaces). APIs allow different software systems to communicate and share data with e 6 min read Node.js fs-extra outputJson() Function The outputJson() function writes an object to the JSON file. If the user wants to write data onto a file that doesn't exist it will be created by the function itself. outputJSON() can also be used in place of outputJson(). Syntax: fs.outputJson(file,object,options,callback) or fs.outputJSON(file,obj 3 min read Node.js fs-extra move() Function The move() function moves a file or a directory from source to the destination specified by the user. If you want to move a file to a folder in which a file with the same name already exists, the function will overwrite the file if we have set the option of overwrite to true else it will throw an er 3 min read Like