Understanding spread

One of my biggest sets of frustrations comes from not being able to understand a concept, method, tool, etc., until I’ve used it a bit. And once it clicks, I can’t understand how I went so long thinking it was complicated to grasp.

Right now, I can’t understand why it took me so long to grasp the array spread operator. I must have read the MDN page half a dozen times, barely retaining enough to remember what it was called. How many times did I Google “three dots js” and close the page, eyes glazed over?

It’s nice, especially since I was just recently introduced to the concept of passing by reference and how that can screw up your immutable data structures. That was a DTC issue, where I just tried to push one object into an array, then use the array again only to find that the data had been changed. That’s how I came across Object.assign, which passes only the values of an object, not a reference to the original.

And that was how the spread operator was explained in The Road to Learn React. It’s like Object.assign, just for arrays (as well as objects in React via babel-plugin-transform-object-rest-spread). And suddenly, I get it. Okay. What’s next?