JavaScript Flashcards
Can you name two programming paradigms important for JavaScript app developers?
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.
What is functional programming?
Functional programming: pure functions, immutability, avoid shared state, declarative…
What is the difference between OOP inheritance and prototype inheritance?
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.
When is classical inheritance an appropriate choice?
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.