javascript-methods Flashcards

1
Q

Why do we log things to the console?

A

It is a way to see our variables in the browser and a good way for debugging

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

What is a method?

A

A function which is a property of an 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

A function is an object, a method is an object reference to a function; whether or not it is assigned to an object property

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

The pop() method

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

The floor() method of the Math object

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

The random() method of the Math object (from 0 to 1) which can be multiplied by the highest random number that you want it to choose from

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

The splice() 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

The push() method adds to the end; unshift() method adds to the beginning

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

The split() method

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

They do not change the original string. You can check using console.log()

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

Roughly how many string methods are there according to the MDN Web docs?

A

More than 30 string methods

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

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

A

No, the return value may not be useful in every situation. For example, push() and unshift() return the new length of the array which may not be necessary

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

Roughly how many array methods are there according to the MDN Web docs?

A

more than 40 array methods

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

What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?

A

MDN

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