Javascript Flashcards
What is the purpose of variables?
to store data
How do you declare a variable?
var
How do you initialize (assign a value to) a variable?
=
What characters are allowed in variable names?
letters, numbers, underscores, or dollar signs
What does it mean to say that variable names are “case sensitive”?
they are specific to how they are typed
What is the purpose of a string?
store and manipulate text
What is the purpose of a number?
to show value that would be number quantity
What is the purpose of a boolean?
to determine if something is true or false
What does the = operator mean in JavaScript?
putting in a value to something
How do you update the value of a variable?
just change the value
What is the difference between null and undefined?
null is an empty value, undefined means the variable has been declared but not defined
Why is it a good habit to include “labels” when you log values to the browser console?
point of reference
Give five examples of JavaScript primitives.
string numbers null undefined values
What data type is returned by an arithmetic operation?
number
What is string concatenation?
combination of 2 or more string values
What purpose(s) does the + plus operator serve in JavaScript?
to add values or concatenate strings
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
adds the value of the right operand to a variable and assigns the result to the variable
What are objects used for?
to group variables or functions
What are object properties?
variables inside objects
Describe object literal notation.
{properties: value}
How do you remove a property from an object?
delete
What are the two ways to get or update the value of a property?
dot notation bracket notation
What are arrays used for?
to be put in a list
Describe array literal notation.
[values, values ];
How are arrays different from “plain” objects?
arrays are numeric will repair themselves if something is deleted
What number represents the first index of an array?
0
How do you calculate the last index of an array?
subtract by 1
What is a function in JavaScript?
series of statements that is repeatable
Describe the parts of a function definition.
function keyword name of function parameter list return statement function
Describe the parts of a function call.
name of the function and arguments if it requires it
What is the difference between a parameter and an argument?
parameter is the name for data that will be used later
arguments is data the
What two effects does a return statement have on the behavior of a function?
allows to return result
Why do we log things to the console?
to debug
What is a method?
function being stored in a property
How is a method different from any other function?
methods have to say where they’re coming from
How do you remove the last element from an array?
pop
How do you round a number down to the nearest integer?
floor
How do you generate a random number?
random
How do you delete an element from an array?
splice
How do you append an element to an array?
push
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 check the return value on mdn
Roughly how many string methods are there according to the MDN Web docs?
alot
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?
30
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN
Give 6 examples of comparison operators.
,=>,<=,||
What data type do comparison expressions evaluate to?
true or false
What is the purpose of an if statement?
making decisions
Is else required in order to use an if statement?
no
Describe the syntax (structure) of an if statement.
if condition(parameter){}
What are the three logical operators?
logical (and or not)
How do you compare two different expressions in the same condition?
using logical and, or
comparison
to repeat over and over again
What data type do comparison expressions evaluate to?
to continue or stop
What is the purpose of a loop?
everytime the code block runs
What is the purpose of a condition expression in a loop?
at the beginning of the loop
What does “iteration” mean in the context of loops?
in the beginning
When does the condition expression of a while loop get evaluated?
before the code block