Setting & Deleting Properties
This lesson will teach you how to set properties using dot operators or square brackets, and how to delete properties.
Setting Values Using Dot Notation
A property being accessed by the dot operator can be set/updated using the assignment operator (=).
Example
Let’s take a look at an example to see the implementation.
Javascript (babel-node)
//creating an object named employeevar employee = {//defining properties of the object//setting data valuesname : 'Joe',age : 20}console.log("Originally age was:",employee.age)//updating the value of "age"employee.age = 24console.log("New age is:",employee.age)
Adding Properties
What if the ...
Ask