ES6 Cool Features Flashcards

1
Q

What is used when you don’t want to reassign the variable?

A

Const

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

What is used when we want to reassign a variable

A

Let

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

What is an old way to declare variable in javaScript and it’s now the weakest keyword to define a variable

A

Var

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

What are the differences between Var, Let and Const

A
  1. The main difference is in the visibility or accessibility in some areas of code, ie. scope
  2. When you declare a variable in a function it is visible only within that function, you can’t access it outside.
  3. Var variables have function scope, while let and const have block scope.
  4. With let we avoid overwriting variables in the outer scope
  5. Another potential issue with var is that it can be referenced before it’s assigned
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What allows us to initialize functions with default values?

A

Default parameters

(These values are used when an argument is either omitted or undefined)

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

What as the name suggests can be included by using the three dots syntax and must be declared at the end of the parameters list?

A

Rest Parameter

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

What is usually used because of it’s shorter syntax, compared to traditional functions.

A

Arrow Functions

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

What is one of the benefit of using a normal function over an arrow function when using the this keyword?

A
  1. When we use a normal function as an object method in the function’s body we can use the this keyword to refer to the object itself.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What has a concise syntax and makes it ideal to use with array processing and accept callback functions, such as sort( ), map( ), and reduce( ) which changes seemingly complex processes into simpler code?

A

Arrow functions

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

In ES6 what operator permits the extraction of values from either objects or arrays into distinct variables?

A

Destructuring

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

What is denoted by three dots “…” and can be used to “unpack” elements of objects, arrays and strings?

A

Spread Operator

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

When the spread operator is applied on objects, it is usually used to combine objects by…

A

copying the properties of an existing object into another one

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

What happens when the Spread operator is applied to a string?

A

It spreads out each individual character of the string into individual characters

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

When applied on arrays, what can also be used to copy all the elements from an array into another, spreading them out in a specified position?

A

Spread opearator

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

Can a Spread operator be used to concatenate two arrays?

A

Yes

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

array.some( )

A

array.some( )

It will return true if at least one element matches the condition specified in the callback, returns false otherwise

17
Q

array.every( )

A

array.every( )

will return true, if each element matches the condition specified in the callback, otherwise will return false

18
Q

array.flat( )

A

array.flat( )

(returns a new array)

with all the elements of the subarrays concatenated one specified depth

19
Q

array.find( )

A

array.find( )

this method finds an element which matches the specified criteria, it returns that element. It stops searching if it finds the element

20
Q

array.findIndex( )

A

array.findIndex( )

same as .find( ) but it returns the index at which the value is found

21
Q

array.fill( )

A

array.fill( )

overwrites all the elements in an array with the specified value

22
Q

array.includes( )

A

array.includes( )

will return true, if the array contains a certain element, and false if not

23
Q

array.slice( )

A

array.slice( )

(returns a new array)

containg the selected elements only. You can select elements by specifying a start index, and optionally an end index