What do these three dots in React do?

前端 未结 29 2619
不思量自难忘°
不思量自难忘° 2020-11-21 23:53

What does the ... do in this React (using JSX) code and what is it called?



        
29条回答
  •  花落未央
    2020-11-22 00:10

    Those are called spreads. Just as the name implies. It means it's putting whatever the value of it in those array or objects.

    Such as :

    let a = [1, 2, 3];
    let b = [...a, 4, 5, 6];
    console.log(b);
    > [1, 2, 3, 4, 5, 6]
    

提交回复
热议问题