Does the object contain the given key? Identical to object.hasOwnProperty(key), but uses a safe reference to the hasOwnProperty function, in case it's been

功能等同于object.hasOwnProperty(key),用于检测对象是否存在该属性.

1 _.has({a: 1, b: 2, c: 3}, "b");
2 => true

源码:

1  _.has = function(obj, key) {
2     return hasOwnProperty.call(obj, key);
3   };

 

 

 

posted on 2012-04-16 22:43  himanhimao  阅读(192)  评论(0编辑  收藏  举报