Elementals.js

Latest Version: 3.7 Final 20 December 2018

Method Object.keysIntersection

Summary:

Compares two objects returning an Array of matching keys

This is a STATIC method and should only be called directly off Object, and not any instances of Object created by the browser or user.

Calling Convention:
Object.keysIntersection(object1, object2)
Parameters
object1
First object to compare
object2
Second object to compare
Returns:
An Array of matching keys, if there are no matches an empty Array is returned. The keys will be in the same order they were in object1.

Examples

var
	test1 = { 'a' : 1, 'b' : 2, 'c' : 3 },
	test2 = { 'b' : 1, 'd' : 2, 'e' : 8 },
	test3 = { 'd' : 5, 'e' : 4, 'f' : 4 };
	
console.log(Object.keysIntersection(test1, test2)); // [ 'b' ]
console.log(Object.keysIntersection(test2, test3)); // [ 'd', 'e' ]
console.log(Object.keysIntersection(test1, test3)); // []

Elementals Object Methods

Methods

Property Key

  • Object
  • Method or Variable
  • "Constant" Variable

Downloads

Advertisement