Way2tutorial Snippet Editor
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JavaScript typeof Operator</title> </head> <body> <pre> <!-- Use pre element for work document.writeln() method --> <script type="text/javascript"> var name = 'Opal Kole'; var age = 48; var married = true; var experience = [2010, 2011, 2012, 2013, 2014]; var message = function(){ console.log("Hello world!"); } var address; document.writeln("name : ", typeof(name)); // Returns "string" document.writeln("name : ", typeof name); // Returns "string" document.writeln("age : ", typeof age); // Returns "number" document.writeln("married : ", typeof married); // Returns "boolean" document.writeln("age : ", typeof experience);// Returns "object" document.writeln("experience: ", typeof message); // Returns "function" document.writeln("address : ", typeof address); // Returns "undefined" </script> </pre> </body> </html>