What is ... in Angular? And what it is called? I'm thinking what is the use of "...flash" in addFlash method where it is a parameter in the array.push()?
And also in the toggleFlash method why there is "..." if we can just use this keyword?
flashs: IFlash[] = [];
flashs$ = new BehaviorSubject<IFlash[]>(this.flashs);
addFlash(flash: IFlash) {
this.flashs.push({
...flash,
show: false,
id: getRandomNumber()
});
}
toggleFlash(id: number) {
const index = this.flashs.findIndex(flash => flash.id === id);
this.flashs = [
...this.flashs.slice(0, index),
{
...this.flashs[index],
show: !this.flashs[index].show
},
...this.flashs.slice(index + 1)
];
this.flashs$.next(this.flashs);
}