A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/javascript/operators/instanceof below:

instanceof ยท WebPlatform Docs

instanceof Summary

Returns a Boolean value that indicates whether or not an object is an instance of a particular class.

Syntax
result = object instanceof class
result
Required. Any variable.
object
Required. Any object expression.
class
Required. Any defined object class.
Examples

The following example shows how to use the instanceof operator.

function objTest(obj){
     var i, t, s = "";
     t = new Array();
     t["Date"] = Date;
     t["Object"] = Object;
     t["Array"] = Array;
         for (i in t){
             if (obj instanceof t[i]) {
                 s += "obj is an instance of " + i + "<br/>";
             }
             else {
                 s += "obj is not an instance of " + i + "<br/>";
         }
     }
     return(s);
 }

 var obj = new Date();
 document.write(objTest(obj));

 
 
 
 
Remarks

The instanceof operator returns true if object is an instance of class. It returns false if object is not an instance of class, or if object is null.

Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4