ES6 Flashcards

1
Q

What is the scope of a variable declared with const or let?

A

block scope

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

What does block scope mean?

A

Within the block

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

What is a code block? What are some examples of a code block?

A

define within { … }, if, for, while,…

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

What is the difference between let and const?

A

let can be reassigned
const cannot be assigned

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

Why is it possible to .push() a new value into a const variable that points to an Array?

A

const is mutable ONLY if it’s object

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

How should you decide on which type of declaration to use?

A

if you want to reassign value in the future use let, otherwise use const.

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

What is the syntax for writing a template literal?

A

backtick () then ${JavaScript Expression}

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

What is “string interpolation”?

A

to create strings by doing substitution of placeholders

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

What is destructuring, conceptually?

A

convenience way to extract property values of an object (in 1 line)

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

What is the syntax for Object destructuring?

A

var/let/const { property1:alias_name = ‘default_value’ , property2, … } = object;

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

What is the syntax for Array destructuring?

A

var/let/const [ element1st, element2nd, …. , element#nth ] = array;

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

How can you tell the difference between destructuring and creating Object/Array literals?

A

{ } or [ ] is on the left side of = then destructuring

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

What is the syntax for defining an arrow function?

A

( ) => { }

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

When an arrow function’s body is left without curly braces, what changes in its functionality?

A

no code block = implicit return (return without return statement)
with { }, will require return keyword to actually return value.
{ } allows for multilines code block

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

How is the value of this determined within an arrow function?

A

the value is determine at the definition time, (parent code block)

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

What is “syntactic sugar”?

A

syntax within a programming language to make things easier to read or to express

17
Q

What is the typeof an ES6 class?

A

function

18
Q

Describe ES6 class syntax.

A

class ClassName {
constructor(…) {
//this.parameter = parameter;
}
methodName(…) {
//definition
}
}

19
Q

What is “refactoring”?

A

the process of restructuring existing computer code without changing its external behavior, intend to improve the design, structure, and/or implementation of the software while preserving its functionality.
- improve code readability and reduced complexity.

20
Q

How are ES Modules different from CommonJS modules?

A

commonJS:
- compact syntax
- designed for synchronous loading
- main use: server
ES modules:
- more compact syntax than common JS
- have support for asynchronous loading and configurable module loading

21
Q

What kind of modules can Webpack support?

A

ECMAScript modules
CommonJS modules
AMD modules
Assets
WebAssembly modules
many more (with Loaders)

22
Q

What is React?

A

a JS library for creating user interfaces.

23
Q

What is a React element?

A

an object that virtually describes the DOM nodes that a component represents

24
Q

How do you mount a React element to the DOM?

A

root = ReactDOM.createRoot(“querySelectedContainer”)
root.render(ReactElement)

25
Q

What is Babel?

A

JavaScript compiler. Toolchain that is mainly used to convert ES 2015+ code into backward compatible version of JS in current and older browsers or environments

26
Q

What is a Plug-in?

A

a software component that adds a specific feature to an existing program.

27
Q

What is a Webpack loader?

A

transformations that are applied to the source code of a module, allow you to pre-process files as you import or load them.

28
Q

How can you make Babel and Webpack work together?

A

install the packages, and make sure the config is correct within the package.json