Javascript General Flashcards

(6 cards)

1
Q

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

A

OOP and Functional Programming are the most often used. OOP allows inheritance via different “classes”. Functional is pure-functions without side effects.

Source: https://medium.com/javascript-scene/10-interview-questions-every-javascript-developer-should-know-6fa6bdf5ad95

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

What is functional programming?

A

Explanation: Using pure functions with no side effects to compose your program.

Use: You avoid mutable data and shared states and instead make use of simple functions. It makes the code more predictable.

Example: Instead of having a function with two parameters that does two tasks, you break it into two functions. Each function would have a single parameter and do a single task.

Source: https://medium.com/javascript-scene/10-interview-questions-every-javascript-developer-should-know-6fa6bdf5ad95

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

What is the difference between classical inheritance and prototypal inheritance?

A

Explanation: Classical instances inherit from class “templates” and create sub-class relationships. They are typically instantiated via constructor functions or the class keyword. Prototypal instances inherit directly from other objects and typically instantiated via factory functions or the Object.create() method.

Use: It’s generally considered better practice to use Prototypal inheritance for a few reasons:
Protoypes are more flexible than classes
The abstraction is only a single level deep
It’s less verbose than using classical inheritance

Source:
https://medium.com/javascript-scene/10-interview-questions-every-javascript-developer-should-know-6fa6bdf5ad95
https://dev.to/crishanks/classical-vs-prototypal-inheritance-2o5a

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

What are the pros and cons of functional programming vs object-oriented programming?

A

to search!!!!!!!

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

What are two-way data binding and one-way data flow, and how are they different?

A

Explanation:
Two-way data: UI fields are bound to model data dynamically. When a UI field changes, the model data changes with it and vice-versa. Side effects can occur.
One-way data: The model is the single source of truth. Changes in the UI signal user intent to the model (or “store” in React). Only the model has the access to change the app’s state. The effect is that data always flows in a single direction. It is deterministic meaning no side effects will occur.

Use: React is a popular framework which uses one-way data flow. Angular on the other hand uses two-way data binding.

Source: https://medium.com/javascript-scene/10-interview-questions-every-javascript-developer-should-know-6fa6bdf5ad95

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

What is asynchronous programming, and why is it important in JavaScript?

A

Explanation: It allows you to run blocking code outside of the single thread so that the program can continue to run while it waits for the blocking code to complete. Javascript is synchronous by nature, but the runtime (browser or node) has an event loop which allows developers to write asynchronous programs.

Use: It is important for user interfaces, where you are waiting for user input, and for network requests, where you are waiting for some data back from a server.

Example: Using async…await and fetch to fetch resources from an API is a common implementation of async programming.

Source: https://medium.com/javascript-scene/10-interview-questions-every-javascript-developer-should-know-6fa6bdf5ad95

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