Three points are known as the distribution operator from Typescript (also from ES7 ).
The spread operator returns all elements of the array. Like every single item:
let myArr = [1, 2, 3];
return [1, 2, 3];
return [...myArr];
It is basically syntactic sugar as it compiles this:
func(...args);
:
func.apply(null, args);
In your case, this will compile:
return [...state, action.payload];
return state.concat([action.payload]);
source
share