how to push values in array
array.push(element)some_array = ["John", "Sally"];
some_array.push("Mike");
console.log(some_array); //output will be =>
["John", "Sally", "Mike"]var vegetables = ['Capsicum',' Carrot','Cucumber','Onion'];
vegetables.push('Okra');
//expected output ['Capsicum',' Carrot','Cucumber','Onion','Okra'];
// .push adds a thing at the last of an arrayconst animals = ['pigs', 'goats', 'sheep'];
const count = animals.push('cows');
console.log(count);
// expected output: 4
console.log(animals);
// expected output: Array ["pigs", "goats", "sheep", "cows"]
animals.push('chickens', 'cats', 'dogs');
console.log(animals);
// expected output: Array ["pigs", "goats", "sheep", "cows", "chickens", "cats", "dogs"]
Also in JavaScript:
- add one file to another in ejs
- in java javascript what is source code
- canvas cut path to image
- javascript get the last element of json
- angular how to get previous state
- nodejs read file to array
- rest parameters
- random color in javascript
- jquery number format thousand k
- javascript uppercase first character of each word
- coreui react change background color
- javascript convert int to float with 2 decimal places
- currentTime(); javascript
- lhow to get determinant of a matrix
- c# newtonsoft serialize dictionary to json
- google sheets get ranges
- the update operation document must contain atomic operators mongodb
- vue get height of element ref
- unpack list javascript
- javascript dir
- weakset in es6
- Redux
- compare two arrays
- moment for react