Data Encapsulation in ES5

This lesson explains the steps to protect properties and teaches us how to access these protected properties.

Hiding Data

Till now, all the constructor function properties were easily accessible outside of it, and their values could be modified without any restrictions. In both ES5 and ES6 versions of JavaScript, there is no formal support for access modifiers using keywords such as public, private or protected. By default, all properties are public; hence, they can easily be accessed.

Let’s discuss property protection for the ES5 version.

Before we get into details, let’s take a ...

Access this course and 1400+ top-rated courses and projects.