xxxxxxxxxx
var db_user = ["user_id", "user_name", "email"];
db_user.push("contact");
xxxxxxxxxx
const arr = [1, 2, 3, 4];
arr.push(5);
console.log(arr); // [1, 2, 3, 4, 5]
// another way
let arr = [1, 2, 3, 4];
arr = [arr, 5];
console.log(arr); // [1, 2, 3, 4, 5]
xxxxxxxxxx
const langages = ['Javascript', 'Ruby', 'Python'];
langages.push('Go'); // => ['Javascript', 'Ruby', 'Python', 'Go']
const dart = 'Dart';
langages = [langages, dart]; // => ['Javascript', 'Ruby', 'Python', 'Go', 'Dart']
xxxxxxxxxx
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
xxxxxxxxxx
const sports = ['Football', 'Tennis']
sports.push('Basketball') // => ['Football', 'Tennis', 'Basketball']
xxxxxxxxxx
var languages = ["JavaScript", "PHP", "Python", "SQL"];
console.log(languages);
languages.push("C");
console.log(languages);
xxxxxxxxxx
let dailyActivities = ['eat', 'sleep'];
// add an element at the end
dailyActivities.push('exercise');
console.log(dailyActivities); // ['eat', 'sleep', 'exercise']