Editor Arrow Download Open
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JavaScript instanceof operator</title> </head> <body> <pre> <!-- Use pre element for work document.writeln() method --> <script type="text/javascript"> var num1 = new Number(15); document.writeln("1:", num1 instanceof Number); // Returns true var num2 = 10; document.writeln("2:", num2 instanceof Number); // Return false document.writeln("3:", true instanceof Boolean); // false document.writeln("4:", 0 instanceof Number); // false document.writeln("5:", "" instanceof String); // false document.writeln("6:", new Boolean(true) instanceof Boolean); // true document.writeln("7:", new Number(0) instanceof Number); // true document.writeln("8:", new String("") instanceof String); // true </script> </pre> </body> </html>
  Preview Arrow