Javascript Essentials Flashcards

1
Q

I know about the event loop IN BROWSER

A

Javascript engine is one engine inside of the browser. Everything that happens in the JS engine is synchronous. However other processes in the browser are asynchronous. Other than the callstack, there is another list that sits inside the JS engine called the Event Queue. This is a list full of events to listen for in the browser. The Event Queue is only looked at by the JS engine only after the call stack is empty. When an event happens that is in the Event Queue, the JS runs the function that was associated with that event being triggered. The browser is continuously looking at the Event Queue for events that occurred. When it sees an event it starts the process again.

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

I know what process.nextTick does

A

Defer the execution of a function until the next Event Loop Iteration.
The difference between setTimeout() and process.nextTick() is that the process.nextTick() function is specific to the Node.js Event Loop. setTimeout() uses JavaScript runtime to schedule its own queue of events. When using process.nextTick(), callback function associated with it runs immediately after events in the Event Queue are processed by the Event Loop in a single iteration. In comparison to setTimeout(), it is faster since queue associated with setTimeout() or the JavaScript runtime.

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

I know about the event loop IN NODE

A

The event loop is what allows Node.js to perform non-blocking I/O operations — despite the fact that JavaScript is single-threaded

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

I know what “let” does

A

let allows you to declare variables that are limited in scope to the block, statement, or expression on which it is used. This is unlike the var keyword, which defines a variable globally, or locally to an entire function regardless of block scope.

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

I know about closures and can find an example usage of it

A

Returning function B from function A. Function B has access to the same variable environment as A even though function A has executed and is popped off the call stack.

EXAMPLE:
creating function factories

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