Array Spread in JavaScript
Level 269 keystrokes
The spread operator (...) expands array elements into individual elements.
JavaScript code
// Create first array with elements 1 and 21let a = [1, 2];// Create second array with elements 3 and 42let b = [3, 4];// Use spread operator to combine both arrays// ...a expands to 1, 2 and ...b expands to 3, 43let c = [...a, ...b];// Print the combined array4console.log(c);Output
[ 1, 2, 3, 4 ]
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this JavaScript code and how often they appear.
.× 7;× 4,× 3[× 3]× 3=× 3(× 1)× 1