javascript-method Flashcards

1
Q

Why do we log things to the console?

A

We log things to the console to debug the code and make sure that variables equal certain values at different points in the code.

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 function that is stored in the 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 method is different from any other function because it is within the scope of an object. Its nearest parent scope is the object that contains it, then the global scope. A function that is not a method has its own scope, then the global scope is its parent scope. When a method is called, the parent object needs to be written. dad.getChildren();

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 last element from an array can be removed using the Array.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

You round a number down to the nearest integer using the Math.floor() method.

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

You generate a random number between 0 and 1 using the Math.random() method.

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

You delete an element from an array by using the Array.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

You append an element to an array using the Array.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

You break up a string into an array using the Array.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

String methods do not change the original string because strings are immutable. To check you would run a string method and then console.log the original string.

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

There are 50 string methods according to the MDN web docs.

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

The return value of a function or method is not useful in every situation. If the function was accessing and changing variables in the global scope or if the function was just meant to alert or console.log it would not need a return.

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

According to the MDN web docs there are 41 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