ES6 - Object.is



This function determines whether two values are the same value.

Syntax

The syntax which is given below is for an object method is(), where,

  • value1 The first value to compare.

  • value2 The second value to compare.

Object.is(value1, value2);

Example

<script>
   let emp1 = {ename:'Prijin'}
   let emp2 = {ename:'Prijin'}
   console.log(Object.is(emp1.ename,emp2.ename))

</script>

The output of the above code will be as seen below −

true
Advertisements