commonKeys

Return the common own property names of two or more objects.

Usage

var commonKeys = require( '@stdlib/utils/common-keys' );

commonKeys( obj1, obj2[, obj3[,...,objN]] )

Returns the common own property names of two or more objects.

var obj = {
    'a': 1,
    'b': 2,
    'c': 3
};

var obj2 = {
    'a': 1,
    'b': 2
};

var keys = commonKeys( obj, obj2 );
// returns [ 'a', 'b' ]

Examples

var commonKeys = require( '@stdlib/utils/common-keys' );

function Foo() {
    this.beep = 'boop';
    this.a = {
        'b': 'c'
    };
    return this;
}

Foo.prototype.foo = [ 'bar' ];

var obj1 = new Foo();

var obj2 = {
    'beep': 'boop',
    'foo': 'bar'
};

var keys = commonKeys( obj1, obj2 );
// returns [ 'beep' ]
Did you find this page helpful?