... What Do The Three Dots Mean In Typescript - Rest Operator
let displayColors = function(message ...colors){};
Looking at this variable function above, you can clearly see the usagave of ... which is called a REST VARIABLE.
I am learning typescript right now, and the way i understand this feature in typescript ECMAScript ES6 is that this can help you create an array. this is very helpful if you want to pass down an array into a function.
this is an example of using Restp operators:
//the spread operator takes an array and splits it into individual elements//this is an example of the REST operatorlet displayColors = function(message ...colors){ console.log(message); console.log(colors); // shows the array properties console.log(arguments.length); // shows how many elements for(let i in colors){ console.log(colors[i]); }}let message = "List of Colors";let colorArray = ['orange','yellow','purple'];displayColors(message,
...colorArray); // HERE IS THE DIFFERENCE BETWEEN REST AND SPREAD. YOU
USE THE THREE DOTS WHEN YOU CALL THE FUNCTION
if you still need help, i learn about rest operators from this video:
REST = TO COMBAINE / SPREAD = SPLIT
https://www.youtube.com/watch?v=Fc6DPYx9aQU&index=14&list=PLC3y8-rFHvwhI0V5mE9Vu6Nm-nap8EcjV