๐ฐproperty testing
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
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.
Every in JavaScript can be classified by 3 factors:
/
enumerable / non-enumerable
own / inherited (from the prototype chain)
๐ MSN
Object โฉ