Share via


in Operator (Windows Scripting - JScript)

 

Tests for the existence of a property in an object.

Syntax

result = property in object

Arguments

  • result
    Required. Any variable.

  • property
    Required. An expression that evaluates to a string expression.

  • object
    Required. Any object.

Remarks

The in operator checks if an object has a property named property. It also checks the object's prototype to see if the property is part of the prototype chain.

The following example illustrates the use of the in operator:

// Create an object that has some properties.
var myObject = new Object();
myObject.name = "James";
myObject.age = "22";
myObject.phone = "555 0234";

if ("phone" in myObject)
   document.write ("property is present");
else
   document.write ("property is not present");

// Output: property is present

Requirements

Version 1

Change History

Date

History

Reason

March 2009

Added example.

Content bug fix.

See Also

Operator Precedence (Windows Scripting - JScript)
Operator Summary (Windows Scripting - JScript)