🔰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/operatorown enumown nonenuminherited enuminherited nonenum

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

📘 MSN

Last updated