Object.getOwnPropertyNamesbeginner// Get all own property names, including non-enumerable
const obj = { a: 1 }
Object.defineProperty(obj, 'hidden', { value: 2, enumerable: false })
Object.getOwnPropertyNames(obj) // β ['a', 'hidden']Use Object.getOwnPropertyNames() to list all own properties including non-enumerable ones, unlike Object.keys().
Object.getOwnPropertyNames(obj) returns an array of all own string-keyed property names, including non-enumerable ones. Unlike Object.keys, it does not filter out non-enumerable properties.
Challenge: Implement getAllNames(obj) that returns all own property names.
getAllNames({ a: 1, b: 2 }) // β ['a', 'b']