Concat const coats1 = [‘solid’, ‘bicolor’, ‘tabby’]; const coats2 = [‘calico’, ‘tortoiseshell’];
Three-dots Tricks
const coats = […coats1, …coats2]; // [‘solid’, ‘bicolor’, ‘tabby’, ‘calico’, ‘tortoiseshell’]
Convert a string to array const str = ‘kitty’;
girliemac.com/blog/ 2020/06/18/ javascript-spread-operator
const newArr = […str]; // [‘k’, ‘i’, ‘t’, ‘t’, ‘y’];
Find the largest const catWeights = [10, 9, 6, 12]; const maxWeight = Math.max(…catWeights); // 12
Remove duplicates from an array const allCatNames =[‘chewie’, ‘leia’, ‘yoda’, ‘chewie’, ‘luke’, ‘leia’]; const catNames = […new Set(allCatNames)]; // [‘chewie’, ‘leia’, ‘yoda’, ‘luke’];