methods Flashcards
Why do we log things to the console?
helps to debug and check for issues
What is a method?
Method is a function which is a property of an object
How is a method different from any other function?
The difference is that a method is associated with an object, while a function is not.
How do you remove the last element from an array?
pop() method removes last element from an array and returns that element. changes length of array
How do you round a number down to the nearest integer?
math.round()
How do you generate a random number?
math.random() range is 0 to under 1
How do you delete an element from an array?
splice()
How do you append an element to an array?
push method pass with no argument
How do you break a string up into an array?
split()
Do string methods change the original string?
How would you check if you weren’t sure? original will not change, will generate new one, check in console.log
Roughly how many string methods are there according to the MDN Web docs?
Is the return value of a function or method useful in every situation?
not if you’re trying to pass more functions or methods within the same codeblock.Roughly how many array methods are there according to the MDN Web docs?