Modern JavaScript Development Flashcards

1
Q

var

A

in the function scope

a variable only exists within the scope of the function in which it’s declared, or the nearest parent function

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

let

A

always block scoped

cannot be hoisted

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

hoisting

A

when the JS interpreter makes two passes at your code. in first pass, the variable and function declarations are “hoisted” to the top of the code. and in the second pass they are evaluated and assignments are made.

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

t/f const variables are immutable

A

false; you can change the value they point to; you cannot change WHERE they point; i.e., you can’t reassign them

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

constructor

A

The constructor is executed automatically when creating a new instance of the class. It guarantees that an initialization function is always called. This helps maintain a valid state for the class. But you don’t have to create a constructor. If one is not included, then the JavaScript engine creates an empty one for you.

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

static methods

A

Static methods are not part of any instance of the class, meaning that you can refer to these methods without referring to an instance. The concept of static class members is not new to ES6, but the static keyword is. Prior to ES6, you had to put any methods you wanted static in the constructor. Now you can put them wherever you want in the class and just use the static keyword.

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

prototype methods

A

These methods do not include the static keyword and must be referenced with an instance.

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

getters and setters

A

These accessor functions work just like object literals and work the same as they did in ES5. Essentially you just put the get and set keywords in front of the property name. If you define a getter without a setter, then the property becomes read-only.

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

BDD

A

Behavior-driven development (BDD) is a process that was born out of Test-driven development (TDD). BDD involves organizing tests such that their behavior is tested, rather than their implementation. When designing these types of tests, think, “How can I describe, in sentence form, what this code does and what I should expect from it.”

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