JAVASCRIPT Flashcards
- How do youdeclarea variable?
var nameOfVariable
- How do you initialize (assign a value to) a variable?
nameOfVariable = sting, number, or boolean
- What characters are allowed in variable names?
letter, underscore, or dollar sign
- What does it mean to say that variable names are “case sensitive”?
superMan will be different than superman
- What is the purpose of a string?
for letters and other characters not considered code
- What is the purpose of a number?
to display numbers
- What is the purpose of a boolean?
to display whether something is true or false - works as switch
- What does the=operator mean in JavaScript?
does not mean equal, means assign
- How do you update the value of a variable?
variableName then assign new value
- What is the difference betweennullandundefined?
null is predictable, set by developer… undefined has no value
- Why is it a good habit to include “labels” when you log values to the browser console?
to identify what our log is
- Give five examples of JavaScript primitives.
string, number, boolean, null, undefined
- What data type is returned by an arithmetic operation?
number
- What is string concatenation?
adding two strings together
- What purpose(s) does the+plus operator serve in JavaScript?
to add two values, string and string, number and number, or mix
- What data type is returned by comparing two values (,===, etc)?
boolean
- What does the+=”plus-equals” operator do?
shorthand operator that adds right operand to left operand and assigns back to left operand
- What are objects used for?
to store information about something
- What are object properties?
variable in the confines of an object, place to store data that can be accessed
later
- Describe object literal notation.
{ property: value };
- How do you remove a property from an object?
delete operator, dot or bracket
- What are the two ways to get or update the value of a property??
dot notation or bracket notation
- What are arrays used for?
to store lists of similar data
- Describe array literal notation.
declare variable/array then assignment, then opening bracket for array, list properties, closing bracket of array
- What is thelengthproperty of an array?
property that tells how many pieces of data are inside array
- How do you calculate the last index of an array?
array.length - 1
- What is a function in JavaScript?
set of steps, instructions, code, that does a specific job
- Describe the parts of a functiondefinition.
function keyword, optional name, optional parameter, (), {, code to run, return}
- Describe the parts of a functioncall.
function name (arguments)
- When comparing them side-by-side, what are the differences between a functioncalland a functiondefinition?
one has arguments one has parameters, function definition has code block
- Why are functionparametersuseful?
it allows a function to pass information
- What two effects does areturnstatement have on the behavior of a function?
returns data/information and replaces the function call - stops function
- What is a method?
methods are functions, property of an object
- How is a method different from any other function?
syntax of method and function differs also a method calls on an object
- How do you remove the last element from an array?
pop () method
- How do you round a number down to the nearest integer?
floor() method
- How do you generate a random number?
Math.random() method
- How do you delete an element from an array?
splice() method
- How do you append an element to an array?
push() method
- How do you break a string up into an array?
split () method
- Do string methods change the original string? How would you check if you weren’t sure?
they don’t, if you want to check, console log it
- Is the return value of a function or method useful in every situation?
No
- Give 6 examples of comparison operators.
, >=, <=, !, &&, ==
- What are the three logical operators?
&& ! ||
- What is the purpose of a loop?
to repeat a block of code as necessary
- What is the purpose of aconditionexpression in a loop?
sets the condition as for when the loop should stop