TypeScript Deck Flashcards

1
Q

Why do we log things to the console? (Methods Topic)

A

to let us see our code and the data we are working with

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

What is a method?

A

a method is a function that is attached to an object in the form of a property. another way of saying this is that a method is a function that is a property of an object. method is a property of our object.

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

How is a method different from any other function?

A

methods belong to objects specifically

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

How do you remove the last element from an array?

A

using the pop method. its written as pop()

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

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

A

using the Math method. it is Math.floor()

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

How do you generate a random number?

A

using the Math method. it is Math.random()

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

How do you delete an element from an array?

A

using the pop() method

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

How do you append an element to an array?

A

using the push() method

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

How do you break a string up into an array?

A

using the split() method, using a specified separator string to determine where to make each split

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

Do string methods change the original string? How would you check if you weren’t sure?

A

string methods do NOT change the original string. you must assign the result of a method call to a new variable in order to store the mutate string. if you aren’t sure you can check the console.log()

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

Is the return value of a function or method useful in every situation?

A

no, because you have two different types of functions. some that do things and others that don’t

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

How do you get a collection of an objects keys?

A

by using the object.keys() method. this returns an array of a given object’s own property names

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

How do you get a collection of an objects values?

A

by using the object.values() method. this returns an array of a given object’s property values

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

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

A

by using the objects.entries() method. this returns an array of the objects’ property names and their values

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

Give 6 examples of comparison operators. (Conditionals Topic)

A

equal ==, not equal !=, strict equal ===, strict not equal !==, greater than >, less than <, greater than or equal >=, less than or equal <=

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

What data type do comparison expressions evaluate to?

17
Q

What is the purpose of an if statement?

A

to check if a condition is true

18
Q

Is else required in order to use an if statement?

A

no, it is optional

19
Q

Describe the syntax (structure) of an if statement.

A

if (boolean expression) then we open a code block that executes if the condition is true

20
Q

What are the three logical operators?

A

logical AND (&&), logical OR (||), logical NOT (!)

21
Q

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

A

using the logical operator

22
Q

What is the purpose of a switch statement?

A

to compare a collection of conditions or cases that need to be checked against each other. it is also more readable and user-friendly compared to else/if statements

23
Q

Is a default clause required in order to use a switch statement?

A

no, it is optional but it is a good way to handle a catch all in case any previous clauses did not execute