0

Can anyone explain for me, what the code below means:

const {Observables} = rxjs

thank you so much!

toan
  • 101
  • 1
  • 8
  • [ES6 destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment). – Phix May 13 '21 at 21:24

1 Answers1

1

Lets say we have two objects person1 and person2 and we have function displayPerson. instead of passing using person.age and person.name, we can destructure them using this line.

   const { age, name } = person; 

Below is an example.

  
person1 = { age: 30, name : "James" }
person2 = { age: 32, name : "Kelly" }


displayPerson = (person) => { 
  const { age, name } = person ; 
  console.log(name + " is " + age.toString() + " years old.")
}


displayPerson(person1)
displayPerson(person2)
Sermet Pekin
  • 357
  • 2
  • 6