Abstraction
In one line
Abstraction is the practice of hiding complex implementation details behind a simple, easy-to-use interface.
In simple words
Abstraction means focusing on what something does rather than how it does it. You create a simple interface that hides the complex details underneath. The user of the abstraction does not need to understand the internals — they just use the interface.
For example, when you call fetch('https://api.example.com') in JavaScript, you do not need to know how HTTP requests, TCP connections, or DNS resolution work. All that complexity is abstracted away behind a single function call.
Abstraction is everywhere: functions abstract away code blocks, classes abstract away state and behavior, modules abstract away implementation, APIs abstract away entire systems. Each layer of abstraction lets you think at a higher level, ignoring lower-level details. The key is: good abstractions simplify without leaking complexity.
Example
// Abstraction: a simple function hides complex logic
function isEmailValid(email) {
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
}
// The caller does not need to understand regex —
// they just use the simple function
console.log(isEmailValid("ada@example.com")); // true
console.log(isEmailValid("not-an-email")); // falseThe regex complexity is hidden behind a simple function. The caller just passes an email string and gets a boolean.
Related terms
Related Resources
Related Lessons
- Programming Paradigms
Learn about abstraction.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.