javascript-methods Flashcards
Why do we log things to the console?
It is a way to see our variables in the browser and a good way for debugging
What is a method?
A function which is a property of an object
How is a method different from any other function?
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 do you remove the last element from an array?
The pop() method
How do you round a number down to the nearest integer?
The floor() method of the Math object
How do you generate a random number?
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 do you delete an element from an array?
The splice() method
How do you append an element to an array?
The push() method adds to the end; unshift() method adds to the beginning
How do you break a string up into an array?
The split() method
Do string methods change the original string? How would you check if you weren’t sure?
They do not change the original string. You can check using console.log()
Roughly how many string methods are there according to the MDN Web docs?
More than 30 string methods
Is the return value of a function or method useful in every situation?
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
Roughly how many array methods are there according to the MDN Web docs?
more than 40 array methods
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN