© 2026 LinearBytes Inc.
Search posts, tags, users, and pages
ShishirB
Software Engineer
Regarding the spread and rest operator, why does it have two names when it does the same thing in both cases? It does spread the values in both cases, right ?
Nikolai Kolesnikov
full stack developer (js, typescript, kotlin, php)
I guess it depends on point of view.
When you declare function it is "rest": function funcName(a, b, ...rest) { console.log(rest); }
When you call function (or fill array, object) and try to pass a few arguments it is "spread":
funcName(...spread); [...spread]; {...spread};