Javascript examples for Data Type:undefined
Put a variable check inside a string
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w w w . j a v a 2 s . co m*/ var variable = true; var mystring = 'The variable ' + (typeof variable !== 'undefined' ? 'exists' : 'doesn\'t exist'); console.log(mystring); } </script> </head> <body> </body> </html>