Object Spread in JavaScript
Level 297 keystrokes
The spread operator (...) can merge objects by copying their properties.
JavaScript code
// Create first object with property a1let obj1 = { a: 1 };// Create second object with property b2let obj2 = { b: 2 };// Use spread to merge both objects into a new one// ...obj1 copies a: 1, ...obj2 copies b: 23let merged = { ...obj1, ...obj2 };// Print the merged object4console.log(merged);Output
{ a: 1, b: 2 }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:× 2,× 1(× 1)× 1