I am confused about the spread syntax and rest parameter in ES2015. Can anybody explain the difference between them with proper examples?
When using spread, you are expanding a single variable into more:
var abc = ['a', 'b', 'c']; var def = ['d', 'e', 'f']; var alpha = [ ...abc, ...def ]; console.log(alpha)// alpha == ['a', 'b', 'c', 'd', 'e', 'f'];
2.1m questions
2.1m answers
60 comments
57.0k users