1.7 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			1.7 KiB
		
	
	
	
	
	
	
	
title
| title | 
|---|
| Object Is | 
Object Is
Description
The object.is() method is used to determine if two values are the same value. This method was introduced in ES6.
Syntax
Object.is(val1, val2)
Parameters
val1 - first value to compare
val2 - second value to compare
Return value
A Boolean indicating whether the two arguments have the same value
Description
Object.is() compares two values for sameness, returning true if both values meet one of the following conditions:
undefinednull- Both 
trueor bothfalse - String of the same length and same characters
 - Same object
 - Both numbers and:
- Both 
+0or both-0 - Both 
NaN - or both a number that is not zero and not 
NaN 
 - Both 
 
Examples
Object.is('string', 'string'); // true
Object.is(undefined, undefined); // true
Object.is(null, null); // true
Object.is('string, 'word'); // false
Object.is(true, false); // false
Object.is([], []); //false  
var obj = {name: Jane};
Object.is(obj, obj); // true
Object.is(NaN, NaN); // true
Object.is(+0, -0); // false
Object.is(-0, -0); // true