Coding interview preparation
5.79K subscribers
368 photos
52 files
163 links
Download Telegram
Top JavaScript interview questions.
What's good to hear in answer and what raises red flag:

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

JavaScript is a multi-paradigm language, supporting imperative/procedural programming along with OOP (Object-Oriented Programming) and functional programming. JavaScript supports OOP with prototypal inheritance.

Good to hear:

Prototypal inheritance (also: prototypes, OLOO).
Functional programming (also: closures, first class functions, lambdas).

Red flags:

No clue what a paradigm is, no mention of prototypal oo or functional programming.

#javascript #js
2. What is functional programming?

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.

Good to hear:

πŸ”Ή 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.

Red flags:

πŸ”» No mention of pure functions / avoiding side-effects.
πŸ”» Unable to provide examples of functional programming languages.
πŸ”» Unable to identify the features of JavaScript that enable FP.

#javascript #js
3. What is the difference between classical inheritance and prototypal inheritance?
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.

In JavaScript, prototypal inheritance is simpler &
more flexible than class inheritance.


Good to hear:
πŸ”Ή Classes: create tight coupling or hierarchies/taxonomies.
πŸ”Ή Prototypes: mentions of concatenative inheritance, prototype delegation, functional inheritance, object composition.

Red Flags:
πŸ”» No preference for prototypal inheritance & composition over class inheritance.

#javascript #js
4. When is classical inheritance an appropriate choice?

The answer is never, or almost never. Certainly never more than one level. Multi-level class hierarchies are an anti-pattern. I’ve been issuing this challenge for years, and the only answers I’ve ever heard fall into one of several common misconceptions. More frequently, the challenge is met with silence.

β€œIf a feature is sometimes useful
and sometimes dangerous
and if there is a better option
then always use the better option.”

~ Douglas Crockford

Good to hear:

πŸ”Ή Rarely, almost never, or never.
πŸ”Ή A single level is sometimes OK, from a framework base-class such as React.Component.
πŸ”Ή Favor object composition over class inheritance.

#javascript #js
5. When is prototypal inheritance an appropriate choice?

There is more than one type of prototypal inheritance:

- Delegation (i.e., the prototype chain).
- Concatenative (i.e. mixins, Object.assign()).
- Functional (Not to be confused with functional programming. A function used to create a closure for private state/encapsulation).

Each type of prototypal inheritance has its own set of use-cases, but all of them are equally useful in their ability to enable composition, which creates has-a or uses-a or can-do relationships as opposed to the is-a relationship created with class inheritance.

Good to hear:

πŸ”Ή In situations where modules or functional programming don’t provide an obvious solution.
πŸ”Ή When you need to compose objects from multiple sources.
πŸ”Ή Any time you need inheritance.

Red flags:

πŸ”» No knowledge of when to use prototypes.
πŸ”» No awareness of mixins or Object.assign().

#javascript #js
PatrickJS/ngExam

An
AngularJS exam with questions from beginner to expert by @gdi2290 from @AngularClass

Creator: PatrickJS
Stars ⭐️: 365
Forked By : 61
GitHub Repo: https://github.com/PatrickJS/ngExam


#PatrickJs #Js #Angular
βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @coding_interview_preparation for more interview questions.
*This channel belongs to @bigdataspecialist group
πŸ‘1