Returns a Boolean value that indicates whether or not an object is an instance of a particular class.
|
---|
result = object instanceof class |
Arguments
-
result
-
Required. Any variable.
-
object
-
Required. Any object expression.
-
class
-
Required. Any defined object class.
Remarks
Example
The following example illustrates the use of the instanceof operator.
| Copy Code |
---|
function objTest(obj){
var i, t, s = ""; // Create variables.
t = new Array(); // Create an array.
t["Date"] = Date; // Populate the array.
t["Object"] = Object;
t["Array"] = Array;
for (i in t)
{
if (obj instanceof t[i]) // Check class of obj.
{
s += "obj is an instance of " + i + "\n";
}
else
{
s += "obj is not an instance of " + i + "\n";
}
}
return(s); // Return string.
}
var obj = new Date();
response.write(objTest(obj)); |
Requirements
See Also