Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Automatic Data Type Conversions</title> </head> <body> <script> document.write("3" - 2); // Prints: 1 document.write("<br>"); document.write("3" + 2); // Prints: "32" (because + is also concatenation operator) document.write("<br>"); document.write(3 + "2"); // Prints: "32" document.write("<br>"); document.write("3" * "2"); // Prints: 6 document.write("<br>"); document.write("10" / "2"); // Prints: 5 document.write("<br>"); document.write(1 + true); // Prints: 2 (because true is converted to 1) document.write("<br>"); document.write(1 + false); // Prints: 1 (because false is converted to 0) document.write("<br>"); document.write(1 + undefined); // Prints: NaN document.write("<br>"); document.write(3 + null); // Prints: 3 (because null is converted to 0) document.write("<br>"); document.write("3" + null); // Prints: "3null" document.write("<br>"); document.write(true + null); // Prints: 1 document.write("<br>"); document.write(true + undefined); // Prints: NaN </script> </body> </html>