For Study Questions (Advanced) Flashcards

1
Q

Describe functional programming in JS.

A

Functional programming produces programs by composing mathematical functions and avoids shared state & mutable data. Lisp (specified in 1958) was among the first languages to support functional programming, and was heavily inspired by lambda calculus. Lisp and many Lisp family languages are still in common use today.
Functional programming is an essential concept in JavaScript (one of the two pillars of JavaScript). Several common functional utilities were added to JavaScript in ES5.

[Eric Elliot, 2015]

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

What is the difference between classical and prototypal inheritance in JS?

A

Class Inheritance: instances inherit from classes (like a blueprint — a description of the class), and create sub-class relationships: hierarchical class taxonomies. Instances are typically instantiated via constructor functions with the new keyword. Class inheritance may or may not use the class keyword from ES6.

Prototypal Inheritance: instances inherit directly from other objects. Instances are typically instantiated via factory functions or Object.create(). Instances may be composed from many different objects, allowing for easy selective inheritance.

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

Name two primary javascript programming paradigms.

A

Prototypal inheritance: prototypes, OLOO (?).

Functional programming: closures, first class functions, lambdas.

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

Describe functional programming buzz words.

A
  • Pure functions / function purity.
  • Avoid side-effects.
  • Simple function composition.
  • Examples of functional languages: Lisp, ML, Haskell, Erlang, Clojure, Elm, F Sharp, OCaml, etc…
  • Mention of features that support FP: first-class functions, higher order functions, functions as arguments/values.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly