instanceof operator returns true if the specified object is an instance of the specified object: - Javascript Operator

Javascript examples for Operator:instanceof

Description

instanceof operator returns true if the specified object is an instance of the specified object:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="demo"></p>

<script>
var cars = ["A","B","C"];

document.getElementById("demo").innerHTML =
    (cars instanceof Array) + "<br>" +
    (cars instanceof Object) + "<br>" +
    (cars instanceof String) + "<br>" +
    (cars instanceof Number);//w  w  w  .  j  a  v a2s .  c o m
</script>

</body>
</html>

Related Tutorials