JavaScript

Encapsulation

Definition

The practice of bundling data and methods that operate on that data within a single unit, while restricting direct access to some of the object's internals. JavaScript uses closures and private class fields (`#`) for encapsulation.

Code Example

Javascript
Tip: Modify the code above and click “Run” to see the results

Learn More

Related Terms