Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Determine If a Variable is a String in JavaScript</title> </head> <body> <script> // Sample variable var myVar = 'Hello'; // Test if variable is a string if(typeof myVar === 'string') { document.write('It is a string.'); } else { document.write('It is not a string.'); } </script> </body> </html>