Changing object elements in JavaScript

Elements of objects can be changed by accessing them by keys. Let's see how it's done. Let's have the following object:

let obj = {a: 1, b: 2, c: 3};

Change the value of its element:

obj['a'] = '!';

Let's use property access:

obj.b = '!';

Check if the object has changed:


Given an object:

let obj = {x: 1, y: 2, z: 3};

Square each element of this object.