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
Given that the variables are declared. Is this valid: console.log(firstName + ‘ ‘ + lastName);
Valid
26
Operator used to assign values to a variable
Assignment operator
27
This operator adds the value of the right operand to a variable and assigns the result to the variable.
addition assignment operator (+=)
28
This operator increments (adds one to) its operand and returns the value before or after the increment, depending on where the operator is placed.
increment operator (++)
29
We use ___________ operators to produce boolean values.
comparison (and of course logical)
30
True or false: The Console tab in developer tools has access to all variables in present in the browser tab.
True
31
JavaScript has a well-defined order of operator ___________. Basically, the order in which operators are executed.
precedence
32
True or false: Comparison operators has lower precedence than arithmetic operators. This means arithmetic operators executes first than comparison operators.
True
33
True or false: Most of the operators execute from left to right, but some execute from right to left like assignment operator.
True
34
True or false: You can declare two empty values: let x, y;
True
35
Give a type of operator that has right to left associativity
Assignment operator or exponential
36
What will be the value of x and y: x = y = 25 - 10 - 5;
10 and 10
37
Which has the highest order of precedence?
Grouping
38
What is the result: const ageAverage = 20 + 20 / 2;
30
39
What is the result: const ageAverage = (20 + 20) / 2;
20
40
It’s easier to building strings using _______________.
Template literal
41
Starting ES6, there’s a much easier way to concatenate strings with __________.
Template literal
42
We use ____________ to write template literals, and we can wrap variables inside of __________.
Backticks (``) and interpolation ${}
43
True or false: You can also write regular strings using template literals.
True
44
You can write multi line strings much easier with ______________.
template literals
45
Use the _______________ to specify a block (code inside curly braces) to be executed if a condition is true.
if statement
46
The ________________ is executed when if statement or else if statement are not executed.
else statement
47
The if else statement is called a _________________. They are commands that enable a program to “take decisions”, following one path or another.
control structure
48
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.
True
49
When we manually convert from one type to another.
Type conversion
50
To convert a string to a number we use the ____________ function.
Number()
51
What happens if we try to use Number() function but the string does not contain number? What will it return?
NaN
52
JS will return _______ when an operators that involves numbers failed to produce a new number. It actually means ______________, not ‘not a number’.
NaN, invalid number
53
Now to convert a number to a string we use _____________ function.
String()
54
When JavaScript automatically converts types behind the scenes for us.
Type coercion
55
True or false: We rarely do type convertions since JS automatically converts types for us.
True
56
True or false: Basically, type coercion happens whenever an operator is dealing with two values that have different types.
True
57
True or false: The plus operator will convert strings to numbers.
False - The plus operator will convert numbers to strings.
58
True or false: The minus operator triggers the opposite conversion, it instead converts strings to numbers.
True
59
True or false: Other arithmetic operators like multiplication and division will convert string to a number.
True
60
True or false: When we compare strings (that looked like numbers) using logical operators, it will result to Error.
False - When comparing the strings it will be converted to numbers automatically.
61
The _______ values are values that are not exactly false, but will become false when we try to convert them into a Boolean.
falsy
62
In JS, there are only five falsy values. These are:
0, empty string, undefined, NaN, null
63
True or false: Everything else, are considered truthy values.
True
64
We use the _______________ function to find out if an expression (or a variable) is truthy or falsy:
Boolean()
65
When does JS do type coercion to Booleans?
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
What are the two types of equality operators?
Strict equality operator (===) and Loose equality operator (==)
67
True or false: Whenever our if block only has one line of code to execute, the use of curly braces is unnecessary.
True
68
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.
type coercion
69
What is the result: console.log(’18’ === 18);
false
70
On the other hand, the ___________________ operator does type coercion.
loose equality operator (==)
71
What is the result: console.log(’18’ == 18);
true
72
What is strict inequality operator syntax looks like?
!==
73
The ________________ is a branch of computer science, which uses true and false values to solve complex logical problems.
Boolean logic
74
We will only learn the three most basic logical operators which are the ______ operators
AND, OR, and NOT
75
Returns true only if two values or more values are true. Basically, it will only return true if all are true.
AND
76
Returns true even if there is only one true.
OR
77
It does not combine multiple values. Instead, this operator only acts on one Boolean value and basically inverts it.
NOT
78
True or false: The NOT operator has lower precedence over the AND and OR operator.
False - The NOT operator has higher precedence over the AND and OR operator.
79
What is the syntax of AND operator?
&&
80
What is the syntax of OR operator?
||
81
What is the syntax of NOT operator?
!
82
An alternative way of writing complicated if else statements
switch statement
83
Write down a boilerplate for a switch statement.
switch(), then curly brackets, inside of it is case:, and should have break;. It also contains a default:
84
True or false: With switch statements, we can run the same code for multiple cases.
True
85
True or false: We don’t need to put break; after every case.
False - We need to put break; after every case.
86
In a switch statement, the __________ will execute if none of the cases are executed. Like else.
default
87
True or false: If you omit the break; the code simply continues executing until it sees a break;.
True
88
An ____________ is a piece of code that produces a value.
expression
89
A bigger piece of code that is executed and which does not produce a value on itself.
statements
90
Term for ‘sequence of actions’
statements
91
In a template literal, we can only put expressions not _____________.
statements
92
What do we call this ${}
Interpolation
93
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 _________________.
conditional (ternary) operator
94
The conditional (ternary) operator is the only JavaScript operator that takes three operands, which are:
The condition, followed by a question mark (?), then an expression to execute if the condition is truthy followed by a colon (:), and finally the expression to execute if the condition is falsy.
95
True or false: The conditional operator allows us to write something similar to an if else statement but all in one line.
True
96
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.
True
97
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?
True
98
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.
True
99
Can you put conditional ternary operator inside the interpolation of a template literal?
Yes. It’s valid.
100
Netscape Navigator, a dominant browser at its time, hired a guy named __________ to create a very first version of JS.
Brendan Eich
101
Brendan Eich creates the very first version of JS in just ___ days. It was called _______, but already had many fundamental features of modern JavaScript!
10, Mocha
102
Mocha changes to __________ and then to JavaScript, in order to attract Java developers. However, JavaScript has almost nothing to do with Java.
LiveScript
103
Microsoft launches IE, then copied JS from Netscape and called it _______.
JScript
104
Year when JS was invented
1995
105
ES6 is also called _______.
ES2015
106
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)
ECMA
107
Year when ES5 is introduced.
2009
108
True or false: Code back all the way from 1997 will still work on modern browsers. This means that modern browsers are backwards compatible.
True
109
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)
Do not break the web
110
JavaScript is not ____________ compatible simply because there is no way browsers from today can understand the updates that is coming from the future.
forwards
111
True or false: It’s still important to understand old JS syntax like ES5.
True - since some older code bases are written in ES5.