Testing if object has multiple properties
Could build your own function that just returns true
/ false
and has any interface.
let example = {
'name': 'thomas'
}
let hasAllProps = (obj, props) => {
let propsTrue = _.chain(props)
.map(prop => _.has(obj, prop))
.without(false)
.value()
return (propsTrue.length === props.length)
}
console.log(hasAllProps(example, ['name'])) // true
console.log(hasAllProps(example, ['age'])) // false