JAVASCRIPT Flashcards
What is the purpose of variables?
to store or remmeber information
How to declare a variable
var and name of variable
How do you initialize (assign a value to) a variable?
=
What characters are allowed in variable names?
$, any character, _, a number as long as its not in the beginning
What does it mean to say that variable names are “case sensitive”?
that capital letters affect it
How do you update the value of a variable?
re declare them
What is the difference between null and undefined?
null is put there by a programmer undefined is there in the absence of anything
Why is it a good habit to include “labels” when you log values to the browser console?
for readability
What data type is returned by an arithmetic operation?
number
What purpose(s) does the + plus operator serve in JavaScript?
concatination and addition
What data type is returned by comparing two values (, ===, etc)?
boolean type
What does the += “plus-equals” operator do?
adds the value to the current value and reasign the variable
What are objects used for?
to combine like information
What are object properties?
allow you to store information
Describe object literal notation.
var object ={}
How do you remove a property from an object?
delete operator
What are the two ways to get or update the value of a property?
. or []
What are arrays used for?
store a list of items
Describe array literal notation.
var array =[];
How are arrays different from “plain” objects?
objects have properties arrays don’t
What number represents the first index of an array?
0
What is the length property of an array?
the number of values in array
How do you calculate the last index of an array?
length -1
What is a function in JavaScript?
an set of instructions
Describe the parts of a function definition.
function name (parameter){code block}
Describe the parts of a function call.
name of function and argument
When comparing them side-by-side, what are the differences between a function call and a function definition?
function definition defines the function.
function call is calling the function
What is the difference between a parameter and an argument?
parameter is just to hold value and has no value.
argument has a value.
Why are function parameters useful?
it can be re used with different arguments
What two effects does a return statement have on the behavior of a function?
it will return code outside of the function, and stops code from running after it
Why do we log things to the console?
to debug
What is a method?
a pre defined function which is a property of an object
How is a method different from any other function?
you can only input arguments on methods, you can modify functions and how they work
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
How do you break a string up into an array?
split
Do string methods change the original string? How would you check if you weren’t sure?
no strings are immutable console.log
Roughly how many string methods are there according to the MDN Web docs?
30
Is the return value of a function or method useful in every situation?
depends not every situation
Roughly how many array methods are there according to the MDN Web docs?
30ish
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
mdn
What data type do comparison expressions evaluate to?
boolean types
What is the purpose of an if statement?
to make a decision
Is else required in order to use an if statement?
no
Describe the syntax (structure) of an if statement.
if (){}
What are the three logical operators?
if, else, if else
How do you compare two different expressions in the same condition?
|| &&
What is the purpose of a loop?
check condition and run code block multiple times
What is the purpose of a condition expression in a loop?
the thing that says start or stop
What does “iteration” mean in the context of loops?
being repeated
When does the condition expression of a while loop get evaluated?
before each iteration
When does the initialization expression of a for loop get evaluated?
before loop starts
When does the condition expression of a for loop get evaluated?
before initial iteration
When does the final expression of a for loop get evaluated?
at the end after iteration
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
break
What does the ++ increment operator do?
increments by 1
How do you iterate through the keys of an object?
for in loop
what does the substr() method do
returns a portion of the string, starting at the specified index and extending for a given number of characters afterwards