Operators

Property presence operator (in)

Try the free JavaScript compiler

Checks whether a property exists in an object or its prototype chain. It does not test the property value or array membership by value. A nonobject right operand throws TypeError.

Formal Syntax & Structure

javascript syntaxjavascript
key in object

Parameters & Attributes

NameTypeDescription
keyproperty keyProperty name or symbol.
objectObjectObject to inspect.

Return Value

boolean

Whether the property exists.

Working Example

Example Snippetjavascript
const a={count:undefined};console.log("count" in a,"missing" in a);
JavaScript Reference