Returns the names of the own properties of an object.
The own properties of an object are those that are defined directly on that object, and are not inherited from the object’s prototype.
getOwnPropertyNames(object)
object
An object
An array of strings that represent all the enumerable properties of the given object.
let vehicle = {
speed: 10,
unit: "km/h",
}
let car = Object.create(vehicle, {
stop: {
value: function() {
this.speed = 0
},
enumerable: true,
writable: true,
configurable: true
}
})
print("vehicle: ", Object.getOwnPropertyNames(vehicle))
print("car: ", Object.getOwnPropertyNames(car))
vehicle: ["speed", "unit"]
car: ["stop"]