just-has
    TypeScript icon, indicating that this package has built-in type declarations

    2.2.1 • Public • Published

    just-has

    Part of a library of zero-dependency npm modules that do just do one thing. Guilt-free utilities for every occasion.

    🍦 Try it

    npm install just-has
    yarn add just-has

    Return a boolen indicating the existence of a deep property, don't throw if parent is undefined

    import has from 'just-has';
    
    const obj = {a: {aa: {aaa: 2}}, b: 4};
    
    has(obj, 'a.aa.aaa'); // true
    has(obj, ['a', 'aa', 'aaa']); // true
    
    has(obj, 'b.bb.bbb'); // false
    has(obj, ['b', 'bb', 'bbb']); // false
    
    has(obj.a, 'aa.aaa'); // true
    has(obj.a, ['aa', 'aaa']); // true
    
    has(obj.b, 'bb.bbb'); // false
    has(obj.b, ['bb', 'bbb']); // false
    
    has(null, 'a'); // false
    has(undefined, ['a']); // false
    
    const obj = {a: {}};
    const sym = Symbol();
    obj.a[sym] = 4;
    has(obj.a, sym); // true

    Install

    npm i just-has

    DownloadsWeekly Downloads

    3,057

    Version

    2.2.1

    License

    MIT

    Unpacked Size

    6.36 kB

    Total Files

    9

    Last publish

    Collaborators

    • angus-c