Tests whether all properties and their values in the base object are present in the objectToTest object.
base
objectToTest
The object to be tested.
The base object containing properties and values to test against.
true if all properties and values in base are present in objectToTest, otherwise false.
true
false
const obj1 = { a: 1, b: 2, c: 3 };const obj2 = { a: 1, b: 2 };console.log(testForObjectExtension(obj1, obj2)); // true Copy
const obj1 = { a: 1, b: 2, c: 3 };const obj2 = { a: 1, b: 2 };console.log(testForObjectExtension(obj1, obj2)); // true
const obj3 = { a: 1, b: 2 };const obj4 = { a: 1, b: 3 };console.log(testForObjectExtension(obj3, obj4)); // false Copy
const obj3 = { a: 1, b: 2 };const obj4 = { a: 1, b: 3 };console.log(testForObjectExtension(obj3, obj4)); // false
const obj5 = { a: 1, b: 2 };const obj6 = { a: 1, b: 2, c: 3 };console.log(testForObjectExtension(obj5, obj6)); // false Copy
const obj5 = { a: 1, b: 2 };const obj6 = { a: 1, b: 2, c: 3 };console.log(testForObjectExtension(obj5, obj6)); // false
Tests whether all properties and their values in the
base
object are present in theobjectToTest
object.