The … syntax in ES6


Recently, I’m studying in React for my Uni subject advanced internet programming, I found something I don’t really understand about an syntax in the tutorial, so I decided to record it there, in order to remember it for the future.

What is …

… is an extend operation operator that add into the ES6, it usually used in the function when there are multiple arguments ( you don’t exactly know how much), or in the array merging.

Where is used?

Sum up all the values

function add(...vals){
  let sum=0;
  for(let i=0;i<vals.length;i++){
  return sum;

So it can be called like this:

> 21

or merging up arrays

var a = [1,2]
var b = [3,4]

so the a will become [1, 2, 3, 4]

Separate string into char array

-> ["h", "e", "l", "l", "o"]

reference from



メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください