Home
<!DOCTYPE html> <html> <body> <h1>Demo: Compare Numbers in JavaScript</h1> <p id="p1">num1 == num2 => </p> <p id="p2">num1 === num2 => </p> <p id="p3">num2 == num3 => </p> <p id="p4">num2 === num3 => </p> <p id="p5">num1 == num3 => </p> <p id="p6">num1 === num3 => </p> <script> var num1 = new Number(100); var num2 = Number(100); var num3 = 100; document.getElementById("p1").textContent += num1 == num2; document.getElementById("p2").textContent += num1 === num2; document.getElementById("p3").textContent += num2 == num3; document.getElementById("p4").textContent += num2 === num3; document.getElementById("p5").textContent += num1 == num3; document.getElementById("p6").textContent += num1 === num3; </script> </body> </html>
Result: