Section 1

Preview this deck

What is a callback?

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (18)

Section 1

(18 cards)

What is a callback?

Front

A function called at the completion of a given task; prevents any blocking and allows other code to be run in the meantime

Back

What is blocking?

Front

Occurs when the execution of additional JavaScript in the Node.js process must wait until a non-JS operation completes Happens because the event loop is unable to continue running JS while a blocking operation is occurring Examples: methods in native modules, synchronous methods in Node.js standard library that use libuv

Back

What is an event loop?

Front

Node.js is single-threaded but supports concurrency via events and callbacks Node.js uses an observer pattern; whenever a task completes, the corresponding event is fired to signal to the event listener that it can be executed Differs from models in many other languages where additional threads may be created to handle concurrent work

Back

How can you avoid callback hell?

Front

Modularization Control flow library Generators or Promises Async/await

Back

What is a renderless component?

Front

Doesn't render any of its own HTML, only manages state and behavior, exposing a single scoped slot that gives the parent/consumer complete control over what should be rendered Enables cleaner separation of presentation and behavior

Back

How would you take advantage of multiple cores in an environment using Node.js?

Front

Spawn child processes Use cluster module, which allows processes to share sockets (enables load balancing over cores)

Back

What is an event emitter?

Front

An object that serves as the core building block in event-driven architectures Simplifies process of handling asynchronous events Enables clean, decoupled code

Back

What is Node.js?

Front

A web application framework built on Google Chrome's JavaScript engine (V8) Comes with runtime environment on which a JS script can be interpreted and executed; this allows execution of JS code on any machine outside of a browser (including server) Also provides a rich library of various JS modules to ease development of web applications

Back

What are all possible falsy expressions?

Front

false, null, NaN, 0, " ", undefined

Back

What is the purpose of the Buffer Class in Node.js?

Front

It is a global class that can be accessed in an application without importing a buffer module A buffer is a type of array containing integers corresponding to raw memory allocation outside of the V8 heap; it cannot be resized

Back

If you had a long-running blocking task in a Node.js API, how would you resolve the locking of the event loop?

Front

Offload to another process via child-spawn Build a distributed worker/queue system

Back

What types of streams are present in Node.js?

Front

Readable, writable, duplex (both read and write), and transform (duplex where output is computed based on input)

Back

What is an error-first callback?

Front

A callback used to pass errors (first parameter) and data (additional arguments)

Back

What is a scoped slot in Vue.js?

Front

Works like passing a callback that accepts data and returns HTML Enables ability to pass parameters from a child component up to the parent/consumer Props are added to the slot element in the child component, and the parent accesses parameters by destructuring them out of the slot-scope attribute

Back

What are streams?

Front

Objects that allow reading or writing of data in a continuous way

Back

What is concurrency in Node.js?

Front

Refers to an event loop's capacity to execute JS callback functions after completing other work Any code expected to run concurrently must allow the event loop to continue running as non-JS operations (e.g., I/O) are occurring

Back

What is the destructuring assignment syntax?

Front

JS expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables

Back

What is a stub, and how does it relate to dependency injection?

Front

A function/program that simulates the behaviors of components/modules Provides canned answers to function calls made during test cases Alternative to dependency injection where the behavior of modules and libraries can be controlled post-hoc during testing

Back