16
Jul
The push() method in JavaScript adds one or more elements to the end of an array. This method modifies the original array and returns the new length of the array. Syntax : array.push(element1, element2, ..., elementN); Enter fullscreen mode Exit fullscreen mode *Example 1.: * const fruits = ["Apple", "Banana"]; fruits.push("Orange", "Mango"); console.log(fruits); // Output: ["Apple", "Banana", "Orange", "Mango"] Enter fullscreen mode Exit fullscreen mode *Example 2.: *How to Dynamically Add Elements Using the push() Method index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Fruit List</title> <link rel="stylesheet" href="https://dev.to/sudhanshu_developer/style.css"> </head> <body> <div id="container"> <h2>Fruit List</h2> <input…