JavaScript Flashcards

1
Q

Can you name two programming paradigms important for JavaScript app developers?

A

JavaScript is multi-paradigm language, that supports imperative/declarative programming along with OOP and Functional Programming. JavaScript supports OOP thanks to its prototypal inheritance system. The functional programming paradigm is supported thanks to tools like: closures, high order functions, arrow functions, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is functional programming?

A

Functional programming: pure functions, immutability, avoid shared state, declarative…

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the difference between OOP inheritance and prototype inheritance?

A

OOP: Classes inherit properties and methods from other classes. Changes on the base class can affect the behavior of the children.

https://codeburst.io/inheritance-is-evil-stop-using-it-6c4f1caf5117

Prototypal inheritance: instances inherit directly from objects. Instances may be composed of many objects, allowing for easy selective inheritance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When is classical inheritance an appropriate choice?

A

Almost never and never more than one level. Multi-level class hierarchies are an anti-pattern like when inheriting from React.Component. Composition should always be favored over inheritance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly