0
createCustomer(customer: Customer): void {
  this.customersRef.add({...customer});
}

I saw this code in the Angular tutorial for firebase. What do these three dots mean? I know either they are used as a spread or rest operator but why it is used here?

And the second question is there any shorter anonymous way by which I can send my interface object by changing only one of its properties?

Example

export interface Person{
  name:string;
  age:number;
  role:string;
}

While saving data in firebase I just get the name and age but the role property is decided at the runtime before adding the record, so is there any easy way where I can just change the role property before submitting the interface values?

misss-popcorn
  • 591
  • 2
  • 12
kushal Baldev
  • 729
  • 1
  • 14
  • 37
  • 4
    Does this answer your question? [What is "..." (3 dots) in javascript?](https://stackoverflow.com/questions/49957500/what-is-3-dots-in-javascript) – Akif Oct 08 '20 at 15:18
  • I saw that before but here does it meant to say that it can accept single object of interface or an array of objects? And probably I want the answer of second question. – kushal Baldev Oct 08 '20 at 15:29

0 Answers0