Tests for the existence of a property in an object.
result = property in object
Required. Any variable.
Required. An expression that evaluates to a string expression.
Required. Any object.
in operator determines whether an object has a property named
property. It also determines whether the property is part of the object's prototype chain. For more information about object prototypes, see Prototypes and Prototype Inheritance.
The following example shows how to use the
// 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
Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported in Store apps (Windows 8 and Windows Phone 8.1). See Version Information.