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
Q

Describe object literal notation.

A

Various key:value pairs are separated by commas between curly braces and assigned to a variable.

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

How do you remove a property from an object?

A

delete variableName[“keyName”]

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

What are the two ways to get or update the value of a property?

A

dot notation and bracket notation

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

What is the purpose of interfaces in TypeScript?

A

Assigning data typing to the values of each property, so that data is not mismanaged upon creation.

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

How do optional properties in a TypeScript interface differ from mandatory properties, and why are they useful?

A

They are not required to create an object in all cases, but may be utilized later in the code.

30
Q

What are arrays used for?

A

storing like data in a indexed way.

31
Q

Describe array literal notation.

A

values within [ ]

32
Q

How are arrays different from “plain” objects?

A

Indexed

33
Q

What number represents the first index of an array?

A

0

34
Q

What is the length property of an array?

A

tells how many items are within an array.

35
Q

How do you calculate the last index of an array?

A

arrayName.length - 1

36
Q

What is a function in JavaScript?

A

a way to systematically package code to be easily reused later in the code.

37
Q

Describe the parts of a function definition.

A

functionKeyword functionName (parameters) {
code block;
return optional;
}

38
Q

Describe the parts of a function call.

A

functionName(arguments);

39
Q

When comparing them side-by-side, what are the differences between a function call and a function definition?

A

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
Q

What is the difference between a parameter and an argument?

A

parameter is the template placeholder in the definition of a function, the argument is what is passed through when the function is called.

41
Q

Why are function parameters useful?

A

Since we won’t know the actual values of what we are passing in, the placeholders are useful.

42
Q

What two effects does a return statement have on the behavior of a function?

A

Breaks the function so that any code under it is unreachable. It also passes a value from the function.

43
Q

What is the syntax for defining an arrow function?

A

const variable = (parameters) => {
codeblock
};

44
Q

When an arrow function’s body is not surrounded in curly braces (concise body syntax), what changes in its functionality?

A

There is an automatic return value if it is in one line.

45
Q

What is a method?

A

a function that exists as a property of an object.

46
Q

How is a method different from any other function?

A

it is specific to the object it exists within.

47
Q

How do you remove the last element from an array?

A

array.pop()

48
Q

How do you round a number down to the nearest integer?

A

Math.floor(number)

49
Q

How do you generate a random number?

A

Math.random()

50
Q

How do you delete an element from an array?

A

array.splice(start, length)

51
Q

How do you append an element to an array?

A

array.push()

52
Q

How do you break a string up into an array?

A

array.split(“character at which to split”)

53
Q

Do string methods change the original string?

A

No

54
Q

How do you get a collection of an objects keys?

A

Object.keys(objectName)

55
Q

How do you get a collection of an objects values?

A

Object.values(objectName)

56
Q

How do you get a collection of both an objects keys and values?

A

Object.entries(objectName)

57
Q

Give 6 examples of comparison operators.

A

===, <, >, <=, >=, !==

58
Q

What is the purpose of an if statement?

A

to process a block of code only if a condition is met.

59
Q

Describe the syntax (structure) of an if statement.

A

ifKeyword (conditional statement) {code}

60
Q

What are the three logical operators?

A

&&, ||, !

61
Q

How do you compare two different expressions in the same condition?

A

AND && or OR ||

62
Q

What is the purpose of a switch statement?

A

to have different actions take place depending on the value of an input.

63
Q

What is the purpose of a loop?

A

To be able to repeat code multiple times on the same or different data.

64
Q

What is the purpose of a condition expression in a loop?

A

To only run the code while a condition is being met.

65
Q

What does “iteration” mean in the context of loops?

A

It references each time a loop is cycled and code is run.

66
Q

When does the condition expression of a while loop get evaluated?

A

Before each time the code is run.

67
Q

When does the initialization expression of a for loop get evaluated?

A

Before the first iteration of the loop.

68
Q
  • When does the condition expression of a for loop get evaluated?
A

Before each iteration of the loop.

69
Q

When does the final expression of a for loop get evaluated?

A

After each iteration of the loop.

70
Q

Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?

A

break;

71
Q

What does the ++ increment operator do?

A

adds 1 to a value and reassigns it to itself.

72
Q

How do you iterate through the keys of an object?

A

a for in loop.