Object.is() method - JavaScript Tutorial

Object.is() method

BLUF: This tutorial on Object.is() method provides an in-depth look at JavaScript's core features. It includes practical examples and code snippets to help you master modern JS development.
Key Discovery: Object.is() method

Understanding Object.is() method is crucial for building dynamic, interactive web applications. Explore the examples below to see it in action.

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:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience