Learn
Objects
Property Assignment (assign and delete)
1. Object.assign()
The Object.assign()
method allows us to copy the values of all enumerable properties from one or more source objects to a target object. It takes in a target object as the first parameter and one or more source objects as subsequent parameters. The method then returns the modified target object.
2. Deleting Properties
To delete a property from an object, we can use the delete
keyword followed by the object name and the property name.
It is important to note that deleting a property removes the property completely from the object, including its value and any associated methods.
Instructions
Inside the car
object, add a new property called color
and set its value to "blue"
.
Delete the year
property from the car
object.
Sign up to start coding
Already have an account?
Sign In