Object.exists >= 0.1.0

Purpose

See if the given path exists inside an object, even if that value is undefined

Syntax

Object.exists ( ObjectobjStringpath );

Parameters

obj

path

The path as a dot-notation string or an array

Return values

Boolean

Examples

var obj = {
    well: {
        test: {
            property: 'one',
            undef: undefined
        }
    }
};

Object.exists(obj, 'well.test.property');
>>> true

Object.exists(obj, 'does.not.exist');
>>> false

Object.exists(obj, 'well.test.undef');
>>> true

Comments