JavaScript Flashcards
What are arrays used for?
store multi same datas
Describe array literal notation.
array name=[]
How are arrays different from “plain” objects?
array has number index, add items to array we use push
What number represents the first index of an array?
0
What is the length property of an array?
the total number of items in array
How do you calculate the last index of an array?
array.length-1
What is a function in JavaScript?
special object can be called. set of reusable code can be used
Describe the parts of a function definition.
function keyword, function-name, parameter, and {code block, optional return}
Describe the parts of a function call.
()
When comparing them side-by-side, what are the differences between a function call and a function definition?
function call will have argument, function definition always will be with code block
What is the difference between a parameter and an argument?
parameter-definition variable
argument-with function call
Why are function parameters useful?
we can have the parameters to create more general data for function to use
What two effects does a return statement have on the behavior of a function?
A return statement ends the execution of a function, and returns control to the calling function.
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. It can be used to alert you that there’s an issue, but shouldn’t take the place of an interactive debugger when it comes time to debug the code.
What is a method?
JavaScript methods are the actions that can be performed on objects. A JavaScript method is a property containing a function definition. Property.
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?
.pop()
How do you round a number down to the nearest integer?
Math.floor()
How do you generate a random number?
Math.random()
How do you delete an element from an array?
.splice(index, delect count)
How do you append an element to an array?
.push()
How do you break a string up into an array?
.split(‘ ‘) the single space separate words
Do string methods change the original string? How would you check if you weren’t sure?
no change. we can use console log to check
Roughly how many string methods are there according to the MDN Web docs?
a lot…