obj-array-helpers
v1.0.6
Published
js-obj-array-helpers
Downloads
2
Readme
Example
Using getObjValue to retrieve values from the object
Using isObject to check if values are objects
import { getObjValue, isObject } from 'obj-array-helpers';
const myObject = {
name: 'John',
age: 30,
address: {
city: 'New York',
country: 'USA'
}
};
console.log(getObjValue(myObject, 'name')); // Output: John
console.log(getObjValue(myObject, 'age')); // Output: 30
console.log(getObjValue(myObject, 'email', 'N/A')); // Output: N/A (since 'email' key does not exist)
console.log(getObjValue(myObject, 'address')); // Output: { city: 'New York', country: 'USA' }
console.log(isObject(myObject)); // Output: true
console.log(isObject(42)); // Output: false
console.log(isObject('Hello')); // Output: false
console.log(isObject(null)); // Output: false
console.log(isObject([1, 2, 3])); // Output: false