TIL spreading an array into another array
POSTED ON:
TAGS: javascript arrays
So to merge an array:
let apples = ['🍎', '🍏'];
let fruits = ['🍉', '🍊', '🍇', ...apples];
let fruitsAppleFirst = [...apples, '🥭', '🍌', '🍒'];
console.log( fruits ); //=> ["🍉", "🍊", "🍇", "🍎", "🍏"]
console.log( fruitsAppleFirst );//=> ["🍎", "🍏", "🥭", "🍌", "🍒"]
Via 10 Awesome JavaScript Shorthands
Related TILs
Tagged: javascript