JS Fundamentals 2 Flashcards

1
Q

Async JS

A

Allows long-running tasks to run in the background without blocking other tasks.
JS Engine has a single thread - it is critical that it not be blocked.

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

Callback Function

A

A function passed into another function as an argument.
Ex: setTimeout(cb, timer)
Ex: Array.map(function(item){ })

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

Callback disadvantages

A

Callback hell - when cbs are chained together / nested
No implicit error state (unlike try/catch)

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

Arrow functions ‘this’

A

“Lexicially or Statically Bound”
Value is det. by WHERE it is DEFINED (enclosing context), not WHERE it is CALLED (regular fns).
Most useful for EVENTS and CALLBACKS.

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

Promises

A

Library to handle async code that makes it easier to determine when code succeeds or fails (resolve, reject). They have built-in mechanisms for chaining (.then) and error handling when called (.catch)

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

Async/Await

A

Syntax that builds on Promises and resembles synchronous JS

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

Destructuring Syntax

A

let numbers = [1, 2, 3];
let [one, two, three] = numbers;
- this creates one two and three as variables w/values 1, 2, and 3 respectively.

const apple = { type: ‘delish’, color: ‘red’ };
const { type, color } = apple;
- creates the variables type and color:
console.log(type) // ‘delish’

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

Template Literals

A

Backticks with ${ } used for string interpolation

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

Lexical Scope

A

Ability of a fn scope to access vars from its parent scope.
ES6 arrow fn syntax has lexical scope built in, regular functions have their own scope.

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

Unknown number of arguments

A

ES6 - ‘rest’ is indicated with …
This can only be used at the end of an argument list.

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

Spread Operator

A

ES6 - includes everything from the array, indicated with …
const array = […array1, …array2];

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

What type is the ES6 Class

A

The JS ‘class’ keyword creates a function not a ‘class’

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

ES6 Class members

A

Constructor
- called automatically when creating a ‘new’ instance, JS creates an empty one for you if you don’t create one
Static Methods
- can refer to the method w/o referring to an instance of the class, uses ‘static’ keyword
Prototype Methods
- must be referenced w/an instance
Getters and Setters
- accessor fns that work like obj literals
- use for validation - check something before setting the value
- use for more control - over how property is accessed and modified

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

ES6 Class Inheritance

A

2 types of classes - ‘base’ and ‘derived’
Derived classes use the ‘extends’ keyword and the ‘super’ keyword, allows you to reference the parent constructor and the method definitions from the base class.

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

ES6 Modules

A

ES6 introduced a native module system.
Import statements get hoisted.

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