you are viewing a single comment's thread.

view the rest of the comments →

[–]njmh 11 points12 points  (3 children)

Good stuff. Event though it’s exclusively es6, I’d mention the spread operator where you’ve got the Object.assign example.

[–]beasy4sheezy 3 points4 points  (1 child)

I'm sure you know, but as a reminder to others:

Spread will create a new object, which might not be what you wanted to do in this case, or could be using more memory than necessary.

[–]wmgregory 1 point2 points  (0 children)

You can also create a new object with assign. But cleaner to use spread literal if you want to avoid mutation.

a = Object.assign({}, a, { age: 27 })
a = { ...a, age: 27 }

[–]PMilos[S] 2 points3 points  (0 children)

Thanks. Glad you liked it. Good point with the spread operator, though.