Object.prototype.hasOwnProperty()
The hasOwnProperty()
method returns a boolean indicating whether the object has the specified property as own (not inherited) property.
Object.assign()
The assign()
method is used to copy the values of all enumerable own properties from one or more source objects to a target object. It will return the target object. Object.assign(target, ...sources)
. Properties in the target object will be overwritten by properties in the sources if they have the same key. Later sources’ properties will similarly overwrite earlier ones. For deep cloning, we need to use other alternatives because Object.assign() copies property values. If the source value is a reference to an object, it only copies that reference value.
Object.keys()
The keys()
method returns an array of a given object’s own enumerable properties, in the same order as that provided by a for…in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well).
Object.defineProperty()
The defineProperty()
method defines a new property directly on an object, or modifies an existing property on an object and returns the object.
Object.defineProperty(obj, prop, descriptor)