ECMAScript 6 defines a new type of operator called the spread operator which does exactly that.
store.add('fruit', 'apple'); store.add('dairy', 'milk', 'cheese', 'yoghurt'); store.add('pastries', 'donuts', 'croissants');
var dairyBox = ['milk', 'cheese', 'yoghurt'];
store.add.apply(store, ['dairy'].concat(dairyBox)); store.add(<span class="hljs-string">'dairy'</span>, ...dairyBox);
Question and answer is powered by AnsPress.io