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