Skip to main content

contains

Check if a key exists in the object.

{a: 1, b: 2}.contains("a"); // true
{a: 1, b: 2}.contains("c"); // false

Syntax

contains(key)

Returns

A boolean indicating whether the key exists or not.

Notes

  • Use this to safely check whether a key exists or not (accessing with [] or . will throw an internal error when the key doesn't exist).