--- id: 587d7dae367417b2b2512b7b title: Understand Own Properties challengeType: 1 videoUrl: '' localeTitle: 了解自己的属性 --- ## Description
在以下示例中, Bird构造函数定义了两个属性: namenumLegs
function Bird(name){
this.name = name;
this.numLegs = 2;
}

让鸭子=新鸟(“唐纳德”);
让金丝雀=新鸟(“特威蒂”);
namenumLegs称为own属性,因为它们直接在实例对象上定义。这意味着duckcanary每个都有自己独立的这些属性的副本。事实上, Bird每个实例都有自己的这些属性的副本。下面的代码将所有的own的性质duck到阵列ownProps
让ownProps = [];

for(let duck in duck){
if(duck.hasOwnProperty(property)){
ownProps.push(属性);
}
}

的console.log(ownProps); //打印[“name”,“numLegs”]
## Instructions
canary own属性添加到数组ownProps
## Tests
```yml tests: - text: ownProps应包含值"numLegs""name" 。 testString: 'assert(ownProps.indexOf("name") !== -1 && ownProps.indexOf("numLegs") !== -1, "ownProps should include the values "numLegs" and "name".");' - text: 无需使用内置方法Object.keys()即可解决此挑战。 testString: 'assert(!/\Object.keys/.test(code), "Solve this challenge without using the built in method Object.keys().");' ```
## Challenge Seed
```js function Bird(name) { this.name = name; this.numLegs = 2; } let canary = new Bird("Tweety"); let ownProps = []; // Add your code below this line ```
## Solution
```js // solution required ```