Object.is() method

The Object.is function in JavaScript serves the purpose of ascertaining whether two values are identical. This method is a special built-in functionality that allows for the comparison of values.

Syntax:

Example

Object.is(value1, value2);

Parameter

value1 : The first value to compare.

value2 : The second value to compare.

Return value:

This function provides a Boolean value that signifies whether the two provided arguments hold the same value or not.

Browser Support:

Chrome 30
Edge Yes
Firefox 22
Opera Yes

Example 1

Example

const object1 = {};
console.log(Object.is(object1));

Output:

Example 2

Example

const object1 = {
  property1: 56
};
console.log(Object.is(object1));

Object.seal(object1);
console.log(Object.isSealed(object1));

Output:

Output

false
true

Example 3

Example

const object1 = {};
console.log(Object.isExtensible(object1));
console.log(Object.is(object1));

Output:

Output

true
false

Input Required

This code uses input(). Please provide values below: