javascript-methods Flashcards
Why do we log things to the console?
to check if our functions are returning the values that we are expecting them to.
its a devs way of talking to the console. it spits out values that we can see
What is a method?
a method is a function that is stored in the property of an object
How is a method different from any other function?
a method does not need to be defined and it is usually attached to an object.
How do you remove the last element from an array?
.pop method
How do you round a number down to the nearest integer?
math.floor method goes DOWN ALWAYS
How do you generate a random number?
Math.random returns a random number between 0 and 1
How do you delete an element from an array?
.splice method.. similar to pop but this allows you to choose your spot
How do you append an element to an array?
.push adds a string to the end of an array
.unshift adds a string to the beginning of an array
How do you break a string up into an array?
.split allows you to break a string up into an array
Do string methods change the original string? How would you check if you weren’t sure?
some can but not all do. in order to see if the string method had any effect on the original string, you would console log it to see the current value
Roughly how many string methods are there according to the MDN Web docs?
50
Is the return value of a function or method useful in every situation?
it depends on the situation.
ex. pop method return doesnt matter sometimes bc u are looking to get rid of the value and trash it
Roughly how many array methods are there according to the MDN Web docs?
a lot -quan
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN