hasProp :: string → { k: v } → Boolean
Takes a string defining a property name and returns a new function evaluation whether the received value (can be of any type) exists and has the defined property.
import hasProp from 'deep-waters/hasProp';
const hasLength = hasProp('length');
hasLength({ length: true }); // → true
hasLength("Hello"); // → true
hasLength([1, 2, 3]); // → true
hasLength({ prop: 1 }); // → false
hasProp does not evaluate whether the received value is strictly of type Object, it only makes sure it has the defined property
Copy link