Quiz Questions Flashcards

1
Q

When was Typescript Introduced and by whom?

A

October 2012 by Microsoft

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

How can you compile Typescript into Javascript

A

change directory (cd folder)
npx tsc –watch

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

What is the purpose of variables?

A

Storing data in a name to be reused.

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

How do you declare a variable?

A

Using keywords const or let.

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

How do you initialize a variable?

A

Using the assignment operator (=)

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

What characters are allowed in variable names?

A

letters, numbers, $, _

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

What does it mean to say that variable names are “case sensitive”?

A

two variables with the same text but different capitalization are different variables and don’t necessarily hold the same value.

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

What is the purpose of a string?

A

Holding text data.

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

What is the purpose of a number?

A

Holding integer and floating point data.

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

What is the purpose of a boolean?

A

To hold true or false data

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

What does the = operator mean in JavaScript?

A

It is the assignment operator and is used to assign value to a variable.

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

How do you update the value of a variable?

A

If the variable is declared with the keyword ‘let’, you can reassign the value of that variable using the assignment operator or an incremental operator like “+=” or “-+”.

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

What is the difference between null and undefined?

A

Null is a value that is purposefully not provided. Undefined has an undeclared value

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

Why is it a good habit to include “labels” when you log values to the browser console?

A

To help clarify what the log is noting.

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

Give five examples of JavaScript primitives.

A

number
string
boolean
null
undefined

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

What data type is returned by an arithmetic operation?

A

Number

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

What is string concatenation?

A

Adds a string and another data type into a string.

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

What purpose(s) does the + plus operator serve in JavaScript?

A

Adds numeric values together, string concatenation, and reassigning variables of other types into number.

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

What data type is returned by comparing two values (<, >, ===, etc)?

A

Boolean

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

What does the += “plus-equals” operator do?

A

Adds the value in the variable with whatever is behind the operator, and then reassigns it to the same variable.

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

What is the syntax for writing a template literal?

A

backtick with string and any ${string interpolation} within

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

What is “string interpolation”?

A

The ability to add variable values into a string

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

What are objects used for?

A

Objects are used to hold various data and their pairs.

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

What are object properties?

A

The “key:value” pair that are housed within an object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Describe object literal notation.
Various key:value pairs are separated by commas between curly braces and assigned to a variable.
26
How do you remove a property from an object?
delete variableName["keyName"]
27
What are the two ways to get or update the value of a property?
dot notation and bracket notation
28
What is the purpose of interfaces in TypeScript?
Assigning data typing to the values of each property, so that data is not mismanaged upon creation.
29
How do optional properties in a TypeScript interface differ from mandatory properties, and why are they useful?
They are not required to create an object in all cases, but may be utilized later in the code.
30
What are arrays used for?
storing like data in a indexed way.
31
Describe array literal notation.
values within [ ]
32
How are arrays different from "plain" objects?
Indexed
33
What number represents the first index of an array?
0
34
What is the `length` property of an array?
tells how many items are within an array.
35
How do you calculate the last index of an array?
arrayName.length - 1
36
What is a function in JavaScript?
a way to systematically package code to be easily reused later in the code.
37
Describe the parts of a function **definition**.
functionKeyword functionName (parameters) { code block; return optional; }
38
Describe the parts of a function **call**.
functionName(arguments);
39
When comparing them side-by-side, what are the differences between a function **call** and a function **definition**?
The block of code and the functionality is created and done within the definition, then simply utilized in the call through the function name.
40
What is the difference between a **parameter** and an **argument**?
parameter is the template placeholder in the definition of a function, the argument is what is passed through when the function is called.
41
Why are function **parameters** useful?
Since we won't know the actual values of what we are passing in, the placeholders are useful.
42
What two effects does a `return` statement have on the behavior of a function?
Breaks the function so that any code under it is unreachable. It also passes a value from the function.
43
What is the syntax for defining an arrow function?
const variable = (parameters) => { codeblock };
44
When an arrow function's body is not surrounded in curly braces (concise body syntax), what changes in its functionality?
There is an automatic return value if it is in one line.
45
What is a method?
a function that exists as a property of an object.
46
How is a method different from any other function?
it is specific to the object it exists within.
47
How do you remove the last element from an array?
array.pop()
48
How do you round a number down to the nearest integer?
Math.floor(number)
49
How do you generate a random number?
Math.random()
50
How do you delete an element from an array?
array.splice(start, length)
51
How do you append an element to an array?
array.push()
52
How do you break a string up into an array?
array.split("character at which to split")
53
Do string methods change the original string?
No
54
How do you get a collection of an objects keys?
Object.keys(objectName)
55
How do you get a collection of an objects values?
Object.values(objectName)
56
How do you get a collection of both an objects keys and values?
Object.entries(objectName)
57
Give 6 examples of comparison operators.
===, <, >, <=, >=, !==
58
What is the purpose of an `if` statement?
to process a block of code only if a condition is met.
59
Describe the syntax (structure) of an `if` statement.
ifKeyword (conditional statement) {code}
60
What are the three logical operators?
&&, ||, !
61
How do you compare two different expressions in the same condition?
AND && or OR ||
62
What is the purpose of a `switch` statement?
to have different actions take place depending on the value of an input.
63
What is the purpose of a loop?
To be able to repeat code multiple times on the same or different data.
64
What is the purpose of a **condition** expression in a loop?
To only run the code while a condition is being met.
65
What does "iteration" mean in the context of loops?
It references each time a loop is cycled and code is run.
66
_When_ does the **condition** expression of a `while` loop get evaluated?
Before each time the code is run.
67
_When_ does the **initialization** expression of a `for` loop get evaluated?
Before the first iteration of the loop.
68
- _When_ does the **condition** expression of a `for` loop get evaluated?
Before each iteration of the loop.
69
_When_ does the **final** expression of a `for` loop get evaluated?
After each iteration of the loop.
70
Besides a `return` statement, which exits its entire function block, which keyword exits a loop before its **condition** expression evaluates to `false`?
break;
71
What does the `++` increment operator do?
adds 1 to a value and reassigns it to itself.
72
How do you iterate through the keys of an object?
a for in loop.