Consider the following statements and tell what would be the output of the logs statements?
var price1 = 10;
var price2 = 10;
var price3 = new Number(\'10\'); // A complex numeric object because new was used.
console.log(price1 === price2);
console.log(price1 === price3);
Consider the following statements and tell what would be the output of the logs statements?
var price1 = 10;
var price2 = 10;
var price3 = new Number(\'10\'); // A complex numeric object because new was used.
console.log(price1 === price2);
console.log(price1 === price3);
Answer
console.log(price1 === price2); // Logs true.
console.log(price1 === price3); /* Logs false because price3
contains a complex number object and price 1
is a primitive value. */
Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website.
If you are using this website then its your own responsibility to understand the content of the website