Imperative vs Declarative
Imperative:
It is a code that says the machine, what to do and how to do.
Ex:
for (let i = 0; i < 1000; i++) {
console.log(i);
}
Declarative:
It is a code that says the machine, what to do and what should happen. It doesn't tell how to do. Ex: Humans
Ex:
[1, 2, 3].forEach(item => console.log(item));
Functional programming is mostly be a declarative, we don't say how to do.
Last updated
Was this helpful?