What do these three dots in React do?

前端 未结 29 3373
不思量自难忘°
不思量自难忘° 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:34

    This a spread operator...

    For example if you have an array first=[1,2,3,4,5] and another second=[6,7,8].

    [...first, ...second] //result is [1,2,3,4,5,6,7,8]

    The same can also be done with json objects.

提交回复
热议问题