JavaScript Object is() Method Last Updated : 12 Jul, 2024 Comments Improve Suggest changes Like Article Like Report JavaScript Object.is() method is used to compare if two values are the same value.Object.is() returns true if the values are the same, and false otherwise. It differs from the strict equality operator === in the handling of NaN and positive/negative zero.Syntax:Object.is(value1, value2)Parameters:Object.is() Method takes two parameters:value1: It is the first value to be compared. value2: It is the second value to be compared.Return Value:Object.is() returns a boolean indicating whether the two arguments are the same or not. Example: In this example, Object.is() returns true for the first comparison because both values are 5, but false for the second comparison because 5 and '5' are of different types. It returns true for NaN comparison because NaN is considered the same value as itself, and false for 0 and -0 comparison because they are considered different values. JavaScript console.log(Object.is(5, 5)); // true console.log(Object.is(5, '5')); // false console.log(Object.is(NaN, NaN)); // true console.log(Object.is(0, -0)); // false Outputtrue false true false Exceptions:The “==” and “===” operator treats the number values “+0” and “-0” as equal but the object.is() method treats them differently.The Object.is() method does not coerce values before comparison even if they are of different data types.Two values can be the same if they hold one of the following properties: If both the values are undefined.If both the values are null.If both the values are true or false.If both the strings are of the same length with the same characters and in the same order.If both the values are numbers and both are “+0” or both are ‘-0’.If both the values are numbers and both are “NaN” or both non-zero and both not NaN and both have the same value. We have a complete list of Javascript Object methods, to check those please go through this JavaScript Object Complete Reference article.Supported Browsers:Google ChromeEdge FirefoxOperaSafari Comment More info S Shubrodeep Banerjee Follow Improve Article Tags : Misc JavaScript Web Technologies javascript-object JavaScript-Methods +1 More Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings6 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in Javascript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)9 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readJavascript Scope3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like