Javascript-methods-Q&A Flashcards
Why do we log things to the console?
console. log specifically is a method for developers to write code to inconspicuously inform the developers what the code is doing
What is a method?
A method is a function which is a property of an object.
How is a method different from any other function?
A method, like a function, is a set of instructions that perform a task. 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?
The pop() method
How do you round a number down to the nearest integer?
The Math.floor() method
How do you generate a random number?
The Math.random() method
How do you delete an element from an array?
The .splice() method
How do you append an element to an array?
The push() method
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?
The replace function returns the new string with the replaces, but if there weren’t any words to replace, then the original string is returned.
Roughly how many string methods are there according to the MDN Web docs?
About 60
Is the return value of a function or method useful in every situation?
Function only has to return a value if the return type of the function in non void i.e if the return type is int,float,double etc.
Roughly how many array methods are there according to the MDN Web docs?
About 50
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN