JS methods Flashcards

1
Q

Why do we log things to the console?

A

to double check work

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

What is a method?

A

method is a function within an object

property holding a function

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

functions are called by name, methods are called by objects

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
.pop( ) EXAMPLE
var numbers = ['1', '2', '3']
console.log(numbers.pop( ) );
return '3'
console.log(numbers);
return ['1', '2']
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
Math.floor( ) EXAMPLE
Math.floor(5.95)
return 5
Math.floor(5.05)
return 5
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

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

.splice( ) EXAMPLE
var months = [‘jan’, ‘march’]
months.splice(1, 0, ‘feb’)
return [‘jan’, ‘feb’, ‘march’]

var months = ['jan', 'feb', 'April']
months.splice(2, 1, 'march')
return ['jan', 'feb', 'march']
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

objectName.push(element)

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

objectName.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

no, console.log(‘string’) or MDN

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

MANY

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

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

MANY

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