对象

hasOwnProperty()

检测传递参数是否有该属性

1
2
3
4
5
6
7
8

function oss(options){
if(!options.hasOwnProperty('host')){
throw new Error('must set host')
}
}
oss({name:"test"});
// will throw Error lack of host