...

/

Setting & Deleting Properties

Setting & Deleting Properties

This lesson teaches how to set properties using dot operator 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.

Press + to interact
Javascript (babel-node)
//creating an object named employee
var employee = {
//defining properties of the object
//setting data values
name : 'Joe',
age : 20
}
console.log("Originally age was:",employee.age)
//updating the value of "age"
employee.age = 24
console.log("New age is:",employee.age)
...

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy