ES6 Flashcards

1
Q

What kind of typed language is JavaScript?

A

JavaScript is a dynamically typed language. The type of variable is infered from the value assigned to it.

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

What exactly are variables?

A

Boxes or containers for storing data. They are named containers and you can use the name to retrieve the value later.

Var, Let, Const

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

What is interpolation? How to do it in ES6?

A

You use backticks and also ${variableName}

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

What is let?

A

Let is very similar to var with the exception that the variable can not be redeclared after declaration var is also scoped to the nearest ‘function block’

Let is scoped to the nearest ‘enclosing block’ - which can be a smaller scope than a function block.

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

What is an escape character?

A

It’s a \ in JavaScript that indicates that the next character should not be read.

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

What are operators?

A

Operators are used to assign values, compare values, perform arithmetic operations and more.

Ternary, binary, unary

Ternary:

condition ? expr1 : expr2

Binary:

1 + 2

Unary Operators

a++

++a

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

What does a switch statement do? How about a do-while loop?

A

color = ‘red’;

switch(red){

color ‘green’:

console…break

default:

}

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

What is the purpose of a function?

A

Functions let you group a series of statement together to perform some task. Once a function is created, it can be reused over and over in your code. If you find yourself repeating statement in your code, then a function may be the answer to avoid that repetition. DRY - Don’t Repeat Yourself

Functions in javascirpt are first class objects…They can have properties and methods just like any other object. Where they DIFFERE< is in the fact that functions can be called

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

Explain hoisting in JavaScript

A

Declared (not assigned) variables are sent to the top. So are functions

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

How do you call an anonymous function?

A

let sayGreeting = function(){}

sayGreeting();

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

What is an IIFE?

A

Immediately Invoked Function Expression

A way to immediately run the function when the pointer/variable is called. So, you have

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

What is a fat arrow function?

A

1) () =>
2) one return statement, no code blocks
3) one parameter, no need to use ()
4) no need to type function

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

Explain the ‘this’ keyword

A

In JS, the thing called this, is the objec that ‘owns’ the JS code

The value of this, when used in a fucntion, is the objec that ‘owns’ the function

The value of this, when used in an object, is the object itself

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

What is an object? What are two ways to construct?

A

It is a value type that contains key value pairs inside {}

Keys are also known as properties

Everything that isn’t a primitive type is an object

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

What are some basic methods for an Array?

A

Pop, push, shift, unshift, concat, reverse, sort (remember you can put condition), slice (remember, slice does not include the last part of the argument,,,2,5 doesn’t not include 5

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

What are some ES6 array helpers?

A

You can use, forEach, like a for loop

You can also use toFixed (1)…fixes the decimal to just 1

Map, takes an array, you can return manipulations on the array values and then return a new arrayu

Filter - Which can return values only based on a condition

Find -