Day 2 Flashcards

1
Q

The _____ and ______ were introduced in ES6, making them a modern JS syntax. They are a new way of declaring variables.

A

let and const

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

While the _____ variable is the old way of declaring variables.

A

var

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

We use _____ keyword to declare variables that can change values later.

A

let

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

When you change the value of a variable, its technical term is called _________ a value.

A

Reassigning or mutating

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

We also use let whenever we want to declare ______________. It is a common practice to declare variables with empty values (usually at the top of the file) and then reassign them later.

A

empty variables

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

On the other hand, we use the _______ keyword to declare variables that are NOT supposed to change at any point in the future. So the values declared with this cannot be changed.

A

const

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

You will get a _______________, if you attempt to change the value of a variable declared with const.

A

TypeError

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

In techical terms, variables declared with const are ___________ variable.

A

immutable

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

True of false: Now the fact that variables created with const are immutable, it also means that we CANNOT declare empty const variables.

A

True

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

True of false: You can declare empty variable with const.

A

False - variables declared with const are immutable.

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

Is this valid: const job;

A

No. You can’t declare an empty variable with const, you need to assign them with an initial value (initializer)

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

Basically, we need an ________ value (or __________) when using const declaration.

A

Initial or initializer

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

True of false: It is a best practice to always use const by default and let only if you are really sure that the variable needs to change at some point in the future.

A

True

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

True of false: It is a best practice to have as little variable mutation or variable changes as possible, because changing variables introduces a potential to create bugs.

A

True

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

Another way to declare variables, but should now be avoided.

A

var

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

Prior to ES6, _____ is used to create variables.

A

var

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

At first sight, it works pretty much the same as let.

A

var

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

True or false: It’s recommended to still use var in modern JavaScript.

A

False - use let or const instead

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

True or false: You can actually declare a variable without the use of let, const, or var but it’s a bad practice, and you’ll learn more later why.

A

True

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

This operators perform arithmetic on numbers (literals or variables).

A

Arithmetic operators

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

True or false: You can log multiple values in console.log(ageJonas, ageSarah)

A

True

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

True or false: You cannot perform arithmetic operations inside of console.log()

A

False - you can

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

What is exponentiation operator looked like?

A

**

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

True or false: We can use the plus operator to join or concatenate strings.

A

True

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

Given that the variables are declared. Is this valid: console.log(firstName + ‘ ‘ + lastName);

A

Valid

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

Operator used to assign values to a variable

A

Assignment operator

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

This operator adds the value of the right operand to a variable and assigns the result to the variable.

A

addition assignment operator (+=)

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

This operator increments (adds one to) its operand and returns the value before or after the increment, depending on where the operator is placed.

A

increment operator (++)

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

We use ___________ operators to produce boolean values.

A

comparison (and of course logical)

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

True or false: The Console tab in developer tools has access to all variables in present in the browser tab.

A

True

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

JavaScript has a well-defined order of operator ___________. Basically, the order in which operators are executed.

A

precedence

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

True or false: Comparison operators has lower precedence than arithmetic operators. This means arithmetic operators executes first than comparison operators.

A

True

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

True or false: Most of the operators execute from left to right, but some execute from right to left like assignment operator.

A

True

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

True or false: You can declare two empty values: let x, y;

A

True

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

Give a type of operator that has right to left associativity

A

Assignment operator or exponential

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

What will be the value of x and y: x = y = 25 - 10 - 5;

A

10 and 10

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

Which has the highest order of precedence?

A

Grouping

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

What is the result: const ageAverage = 20 + 20 / 2;

A

30

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

What is the result: const ageAverage = (20 + 20) / 2;

A

20

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

It’s easier to building strings using _______________.

A

Template literal

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

Starting ES6, there’s a much easier way to concatenate strings with __________.

A

Template literal

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

We use ____________ to write template literals, and we can wrap variables inside of __________.

A

Backticks (``) and interpolation ${}

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

True or false: You can also write regular strings using template literals.

A

True

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

You can write multi line strings much easier with ______________.

A

template literals

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

Use the_______________ to specify a block (code inside curly braces) to be executed if a condition is true.

A

if statement

46
Q

The ________________ is executed when if statement or else if statement are not executed.

A

else statement

47
Q

The if else statement is called a _________________. They are commands that enable a program to “take decisions”, following one path or another.

A

control structure

48
Q

True or false: It’s important to remember that any variables we declare inside of a code block cannot be accessible outside of the code block.

A

True

49
Q

When we manually convert from one type to another.

A

Type conversion

50
Q

To convert a string to a number we use the ____________ function.

A

Number()

51
Q

What happens if we try to use Number() function but the string does not contain number? What will it return?

A

NaN

52
Q

JS will return _______ when an operators that involves numbers failed to produce a new number. It actually means ______________, not ‘not a number’.

A

NaN, invalid number

53
Q

Now to convert a number to a string we use _____________ function.

A

String()

54
Q

When JavaScript automatically converts types behind the scenes for us.

A

Type coercion

55
Q

True or false: We rarely do type convertions since JS automatically converts types for us.

A

True

56
Q

True or false: Basically, type coercion happens whenever an operator is dealing with two values that have different types.

A

True

57
Q

True or false: The plus operator will convert strings to numbers.

A

False - The plus operator will convert numbers to strings.

58
Q

True or false: The minus operator triggers the opposite conversion, it instead converts strings to numbers.

A

True

59
Q

True or false: Other arithmetic operators like multiplication and division will convert string to a number.

A

True

60
Q

True or false: When we compare strings (that looked like numbers) using logical operators, it will result to Error.

A

False - When comparing the strings it will be converted to numbers automatically.

61
Q

The _______ values are values that are not exactly false, but will become false when we try to convert them into a Boolean.

A

falsy

62
Q

In JS, there are only five falsy values. These are:

A

0, empty string, undefined, NaN, null

63
Q

True or false: Everything else, are considered truthy values.

A

True

64
Q

We use the _______________function to find out if an expression (or a variable) is truthy or falsy:

A

Boolean()

65
Q

When does JS do type coercion to Booleans?

A

When you use a value (other than Boolean) as condition to your if statements. It will convert them to either truthy or falsy value.

66
Q

What are the two types of equality operators?

A

Strict equality operator (===) and Loose equality operator (==)

67
Q

True or false: Whenever our if block only has one line of code to execute, the use of curly braces is unnecessary.

A

True

68
Q

The strict equality operator is strict because it does not perform ______________. It only returns true if both values are exactly the same and its type is also the same.

A

type coercion

69
Q

What is the result: console.log(’18’ === 18);

A

false

70
Q

On the other hand, the ___________________ operator does type coercion.

A

loose equality operator (==)

71
Q

What is the result: console.log(’18’ == 18);

A

true

72
Q

What is strict inequality operator syntax looks like?

A

!==

73
Q

The ________________ is a branch of computer science, which uses true and false values to solve complex logical problems.

A

Boolean logic

74
Q

We will only learn the three most basic logical operators which are the ______ operators

A

AND, OR, and NOT

75
Q

Returns true only if two values or more values are true. Basically, it will only return true if all are true.

A

AND

76
Q

Returns true even if there is only one true.

A

OR

77
Q

It does not combine multiple values. Instead, this operator only acts on one Boolean value and basically inverts it.

A

NOT

78
Q

True or false: The NOT operator has lower precedence over the AND and OR operator.

A

False - The NOT operator has higher precedence over the AND and OR operator.

79
Q

What is the syntax of AND operator?

A

&&

80
Q

What is the syntax of OR operator?

A

||

81
Q

What is the syntax of NOT operator?

A

!

82
Q

An alternative way of writing complicated if else statements

A

switch statement

83
Q

Write down a boilerplate for a switch statement.

A

switch(), then curly brackets, inside of it is case:, and should have break;. It also contains a default:

84
Q

True or false: With switch statements, we can run the same code for multiple cases.

A

True

85
Q

True or false: We don’t need to put break; after every case.

A

False - We need to put break; after every case.

86
Q

In a switch statement, the __________ will execute if none of the cases are executed. Like else.

A

default

87
Q

True or false: If you omit the break; the code simply continues executing until it sees a break;.

A

True

88
Q

An ____________ is a piece of code that produces a value.

A

expression

89
Q

A bigger piece of code that is executed and which does not produce a value on itself.

A

statements

90
Q

Term for ‘sequence of actions’

A

statements

91
Q

In a template literal, we can only put expressions not _____________.

A

statements

92
Q

What do we call this ${}

A

Interpolation

93
Q

We already saw two ways of writing conditionals. The regular if else statement and switch statement. But there is another one, and that is the _________________.

A

conditional (ternary) operator

94
Q

Theconditional (ternary) operatoris the only JavaScript operator that takes three operands, which are:

A

The condition, followed by a question mark (?), then an expression to execute if the condition istruthyfollowed by a colon (:), and finally the expression to execute if the condition isfalsy.

95
Q

True or false: The conditional operator allows us to write something similar to an if else statement but all in one line.

A

True

96
Q

True or false: It’s called ternary operator because it has three parts: the condition, the code executed for if part, and then the code executed for the else part.

A

True

97
Q

True or false: Now the conditional operator is in fact an operator, and an operator always produces a value. So in other words an operator is an expression, right?

A

True

98
Q

True or false: The ternary operator does not replace the if else statement, we still need if else statement when we’re writing code that needs more option (else if). The ternary operator is only good when we just need a quick decision.

A

True

99
Q

Can you put conditional ternary operator inside the interpolation of a template literal?

A

Yes. It’s valid.

100
Q

Netscape Navigator, a dominant browser at its time, hired a guy named __________ to create a very first version of JS.

A

Brendan Eich

101
Q

Brendan Eich creates the very first version of JS in just ___ days. It was called _______, but already had many fundamental features of modern JavaScript!

A

10, Mocha

102
Q

Mocha changes to __________ and then to JavaScript, in order to attract Java developers. However, JavaScript has almost nothing to do with Java.

A

LiveScript

103
Q

Microsoft launches IE, then copied JS from Netscape and called it _______.

A

JScript

104
Q

Year when JS was invented

A

1995

105
Q

ES6 is also called _______.

A

ES2015

106
Q

They need to standardize the language, __________ releases ECMAScript 1 (ES1), the first official standard for JS (ECMAScript is the standard, JS is the language in practice)

A

ECMA

107
Q

Year when ES5 is introduced.

A

2009

108
Q

True or false: Code back all the way from 1997 will still work on modern browsers. This means that modern browsers are backwards compatible.

A

True

109
Q

The concept of _______________ means that there is almost never anything removed from the language, but only added in new versions. Not really new versions, just incremental updates (releases)

A

Do not break the web

110
Q

JavaScript is not ____________ compatible simply because there is no way browsers from today can understand the updates that is coming from the future.

A

forwards

111
Q

True or false: It’s still important to understand old JS syntax like ES5.

A

True - since some older code bases are written in ES5.