Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Perform Data Type Conversions Using Operators</title> </head> <body> <script> let x = "10"; // x is a string let y = +x; document.write(typeof(y) + "<br>"); // Prints: number document.write(y + "<br>"); // Prints: 10 let x = 10; // x is a number let y = x + ""; document.write(typeof(y) + "<br>"); // Prints: string document.write(y + "<br>"); // Prints: 10 let x = "15"; // x is a string let y = x - 0; document.write(typeof(y) + "<br>"); // Prints: number document.write(y + "<br>"); // Prints: 15 let x = "123"; document.write(typeof(!!x) + "<br>"); // Prints: boolean document.write(!!x + "<br>"); // Prints: true let x = "Hello World!"; let y = +x; document.write(typeof(y) + "<br>");// Prints: number document.write(y + "<br>"); // Prints: NaN </script> </body> </html>