Kevin Powell - CommunityKP-C
Kevin Powell - Communityโ€ข15mo agoโ€ข
59 replies
snxxwyy

rest operator | ...

Hey, I've looked into the rest operator and came to my own conclusion that it handles a group of things allowing them to be placed somewhere else. I've mainly seen it being useful in situations regarding objects and lists e.g.
const john = {
  name: "John",
  age: "25",
  occupation: "builder"
}
const bob = {
  ...john,
  name: "bob"
}

let numberList = [1, 2, 3]
let concatList = [...numberList, 4, 5, 6]

I can't help but think that something else i've seen does something similar if not the same thing since i've never come across an operator like this before, i just can't put my finger on it. I'm pretty sure you can add two lists for example using + or something like that so i'm not entirely sure why there would be a need for an operator that let's you do this? what does the rest operator really do? Is there a special functionality i'm missing?

Thanks in advance.
Was this page helpful?