Methods Flashcards
Why do we log things to the console?
To show what the code is doing; debugging. To see what data we are working with.
What is a method?
Actions that can be performed on objects.
A property containing a function definition.
How is a method different from any other function?
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, shift( ).
How do you append an element to an array?
The push( ).
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?
All string methods return a new string. They don’t modify the original string. Strings cannot be changed, only replaced.
Console.log( ) to check.
Roughly how many string methods are there according to the MDN Web docs?
50ish
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?
40ish
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN