JS: Object.hasOwn
(new in JS: ECMAScript 2022)
Object.hasOwn(obj, prop)
-
return true if obj has own property prop. Else false.
similar to JS: Object.prototype.hasOwnProperty 👎 but better. because it is a static method, still works if object has no parent, or has property
"hasOwnProperty"
.const xx = { "p": 1 }; console.log(Object.hasOwn(xx, "p")); // true