【问题标题】:Javascript syntax: const {Observables} = rxjs [duplicate]Javascript 语法: const {Observables} = rxjs [重复]
【发布时间】:2021-05-13 21:19:59
【问题描述】:

谁能帮我解释一下,下面的代码是什么意思:

const {Observables} = rxjs

非常感谢!

【问题讨论】:

标签: javascript ecmascript-6 syntax rxjs observable


【解决方案1】:

假设我们有两个对象 person1 和 person2,我们有函数 displayPerson。 我们可以使用这一行来解构它们,而不是使用 person.age 和 person.name 传递。

   const { age, name } = person; 

下面是一个例子。

  
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)

【讨论】:

  • 非常感谢,admionto
猜你喜欢
  • 1970-01-01
  • 2017-06-22
  • 2020-02-10
  • 2016-07-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-12
  • 2017-05-14
相关资源
最近更新 更多