obj-array-helpers
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i obj-array-helpers

Weekly Downloads

1

Version

1.0.6

License

ISC

Unpacked Size

14.8 kB

Total Files

5

Last publish

Collaborators

  • enzoyee