You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
491 B
26 lines
491 B
var hasOwnProp = require('./hasOwnProp')
|
|
|
|
/**
|
|
* 判断对象是否包含该值,成功返回true否则false
|
|
*
|
|
* @param {Object} obj 对象
|
|
* @param {Object} val 值
|
|
* @return {Boolean}
|
|
*/
|
|
function includes (obj, val) {
|
|
if (obj) {
|
|
if (obj.includes) {
|
|
return obj.includes(val)
|
|
}
|
|
for (var key in obj) {
|
|
if (hasOwnProp(obj, key)) {
|
|
if (val === obj[key]) {
|
|
return true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
module.exports = includes
|
|
|