Abstraction
Last updated
Last updated
Abstraction in JavaScript refers to the concept of hiding complex implementation details and showing only the essential features of an object or function.
It allows developers to work with high-level ideas rather than dealing with low-level implementation complexities.
In this example, Car
is an abstraction. It abstracts away the internal details of what makes a car work and provides a simple interface (properties and methods) to interact with it.
As a user of the Car
object, you don't need to know how the engine starts or stops internally;
you simply call start()
or stop()
methods, abstracting away the complexities of the underlying implementation.
Abstraction allows us to think about a car in terms of what it does (start, stop) and what properties it has (make, model, year), without worrying about how those actions are implemented under the hood.
This separation of concerns makes our code more manageable, modular, and easier to maintain.