js methods Flashcards
Why do we log things to the console?
to debug and track our code in ways the average user wouldn’t detect
What is a method?
a function which is a property of an object
How is a method different from any other function?
it belongs to an object
How do you remove the last element from an array?
array.pop()
How do you round a number down to the nearest integer?
Math.floor(number)
How do you generate a random number?
Math.random() generates number from 0 - 0.999…
How do you delete an element from an array?
array.shift() deletes from beginning,
array.pop() deletes from end
splice??
How do you append an element to an array?
array. unshift(element) appends to beginning
array. push(element) appends to end
How do you break a string up into an array?
string.split();
Do string methods change the original string? How would you check if you weren’t sure?
no, console.log(original string) to check
Roughly how many string methods are there according to the MDN Web docs?
33
Is the return value of a function or method useful in every situation?
no?
Roughly how many array methods are there according to the MDN Web docs?
34
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
mdn