Learn JavaScript

Hidden properties

We can use a symbol to create a key to an object property that can not be easily accessed by other parts of the code. These are the hidden properties of the object.

In the example given above, the first console.log statement shows the name property. It does not show the age property because the name property is hidden. We need square brackets to access the age property.