686 B
686 B
title | localeTitle |
---|---|
Understand Own Properties | 了解自己的属性 |
了解自己的属性
方法:
在给出的示例代码中,您将看到一个新数组ownProps[]
intialised,然后是for...in
语句循环遍历duck
的属性,然后使用push()
语句填充新数组。对于canary
对象必须遵循相同的方法。
只需将'for ... in'语句中的duck
对象替换为canary
对象即可传递所有测试用例。
解:
let canary = new Bird("Tweety");
let ownProps = [];
// Add your code below this line
for(let property in canary) {
if(canary.hasOwnProperty(property)) {
ownProps.push(property);
}
}