๐Ÿ”ฐproperty testing

check whether an object has a property.

'prop' in obj                     // in operator
Object.hasOwn(obj, 'prop')        // recommended
obj.hasOwnProperty('prop')        // not recommended
obj.propertyIsEnumerable('prop')

โญ the following methods/operators all support String / Symbol keys.

method/operator
own enum
own nonenum
inherited enum
inherited nonenum
โœ…
โœ…
โœ…
โœ…
โœ…
โœ…
โœ…
โœ…

Every property in JavaScript objects can be classified by 3 factors:

๐Ÿ“˜ MSN

Last updated