.hasOwnProperty(propname)方法来检查对象是否有该属性。如果有返回true,反之返回false。
示例
```js
var myObj = {
top: "hat",
bottom: "pants"
};
myObj.hasOwnProperty("top"); // true
myObj.hasOwnProperty("middle"); // false
```
checkObj检查myObj是否有checkProp属性,如果属性存在,返回属性对应的值,如果不存在,返回"Not Found"。
checkObj("gift")应该返回"pony"。
testString: assert(checkObj("gift") === "pony");
- text: checkObj("pet")应该返回"kitten"。
testString: assert(checkObj("pet") === "kitten");
- text: checkObj("house")应该返回"Not Found"。
testString: assert(checkObj("house") === "Not Found");
```