Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Convert a Number to String</title> </head> <body> <script> var num = 123; document.write(typeof num); // Prints: number document.write("<br>"); var str = num.toString(); // Becomes a string "123" document.write(typeof str); // Prints: string </script> </body> </html>