ES6 Flashcards

1
Q

Features of ES6

A
  • arrow functions
  • let/const
  • template literals
  • Classes
  • destructuring
  • Async & await
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Let/Const scope

A

Block scope = local scope

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

Arrow functions allows a ____ for writing function expressions.

A

short syntax

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

Arrow functions do not have their own ___. They are not well suited for defining object methods.

A

this

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

Arrow functions are not ___. They must be defined before they are used.

A

hoisted

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

You can only omit the ___ keyword and the curly brackets if the function is a single statement. Because of this, it might be a good habit to always keep them:

A

return

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

JavaScript Classes are __ for JavaScript Objects.

A

templates

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

Make a class Car with name property

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

When you have a class, you can use the class to create objects:

For example create myCar2 using class Car

A

let myCar2 = new Car(“Audi”, 2019);

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

___ are a cleaner and more beautiful way to play with strings.

A

Template literals

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

They get rid of the need for a lot of + signs to concat strings.

A

Template literals

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

Destructuring Objects: get firstName and lastName using it

let information = { firstName: 'Dylan', lastName: 'Israel'};

A

let { firstName, lastName } = information;

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

Destructuring Arrays

Point to first element of the array with firstname

['Dylan', 'Israel'];

A

let [firstName] = ['Dylan', 'Israel'];

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

____ allow you to omit the key in the object if the name of the key and value are the same.

A

object literal

17
Q

let firstName = 'Dylan';

// avoid key this is an example of:

let information = { firstName };

A

Object literal

So, in the example above, we wanted to add the property of firstName in our information object. The firstName variable is another variable with the same name. We omit the key and just pass the name of the variable, and it will create the property and assign value itself.

18
Q

, which creates a loop that iterates over iterable objects like String, Array, NodeList objects,

A

for .. of

19
Q

let str = 'hello';

Please use the new loop

A

for (let char of str) { console.log(char);}

// "h"// "e"// "l"// "l"// "o"

20
Q

Name of this functionality

A

Spread operator

The code above demonstrates one of the many cool implementations of using the spread operator. Here we are combining two arrays by putting them in a new array with three dots (…) in front of the name of the array.

21
Q

___ helps us handle function parameters in a better way by allowing us to represent the variable number of the function parameters as an array.

A

rest operator

22
Q

Here, we are calling the same function with a different number of parameters, and the ____ operator is handling that perfectly for us.

A

rest operator

23
Q

Using the ___ method, we can find out if any string contains a particular character or a substring. In this lesson, you will learn in detail about the practical use-cases of this function.

A

includes

24
Q

We all know how important it is to have modular code, especially if you are working on large-scale applications. With ___ and ___ statements in JavaScript, it has become extremely easy and clean to declare and use modules.

A

import and export

25
Q

// exports function

export function double(num) { return num * num; }

In the code above, we are exporting a function by the name of double. We’re then importing the function in a separate file

A

// imports function

import { double } from '..filepath/filename

26
Q

ES2017 introduced two new methods to manipulate strings, which you will learn in detail in this part. ___ and __ will simply add padding at the start and end of the string.

A

padStart and padEnd

27
Q

With ___, we can write asynchronous code which looks like synchronous code.

A

Async & Await

28
Q

Promises

A

a promise represents something async, it can be avaible now, in the future or never.

29
Q

a promise function has two arguments

A

resolve and reject

30
Q

sintax of promise

A
31
Q

Explain the promise

A

Explain the promise