append item to array javascript
var colors=["red","white"];
colors.push("blue");//append 'blue' to colorsvar colors= ["red","blue"];
colors.push("yellow"); arr.push(item);let chocholates = ['Mars', 'BarOne', 'Tex'];
let chips = ['Doritos', 'Lays', 'Simba'];
let sweets = ['JellyTots'];
let snacks = [];
snacks.concat(chocholates);
// snacks will now be ['Mars', 'BarOne', 'Tex']
// Similarly if we left the snacks array empty and used the following
snacks.concat(chocolates, chips, sweets);
//This would return the snacks array with all other arrays combined together
// ['Mars', 'BarOne', 'Tex', 'Doritos', 'Lays', 'Simba', 'JellyTots']
const arr1 = [1,2,3]
const newValue = 4
const newData = [...arr1, obj] // [1,2,3,4]
Also in JavaScript:
- how to sho the active navigation ling using javascript
- angular mouseenter
- useeffect with cleanup
- reverse a linked list javascript
- fetch api react
- how to create an html element in javascript without document
- webpack react proxy not working
- get element by id in Jquery
- how to deep copy an object in javascript
- get client id socket io
- alternate color to table row jquery
- javascript reverse array
- js detect right key click
- how to call a function in react with arguments onclick
- ajax data post call in javascript
- how to use hooks react
- return this javascript
- jquery remove elemtns
- vue js access data in method
- jquery change text of div
- how to make and add to an array in javascript
- how to revert angular cli version
- javascript delete key from object
- javascript how to split array into subarrays javascript