JS Methods Flashcards
What is a method?
A function that is a property of an object.
How do you round a number down to the nearest integer?
Math.floor()
How do you remove the last element from an array?
Array.pop()
How do you delete an element from an array?
Array.splice()
How do you break a string up into an array?
Object.split()
How do you append an element to an array?
Array.push()
Roughly how many string methods are there according to the MDN Web docs?
About 30ish.
Roughly how many array methods are there according to the MDN Web docs?
About 30ish.
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN
Do string methods change the original string? How would you check if you weren’t sure?
No? But if you’re not sure check MDN <b><i>OR</i></b> log it into the console and try it yourself.
Is the return value of a function or method useful in every situation?
No. Sometimes you don’t need to save returns.
Only save the ones you need.
How is a method different from any other function?
The syntax is different. The function is called with the object.
Why do we log things to the console?
It is a great learning tool (use it to play and learn about JavaScript).
Also used as a debugging tool during app development.
How do you generate a random number?
Math.random() — Think of it as a range between 0 and 1 (not inclusive of 1); so you get decimal (think of decimal as a percentage)