JavaScript Flashcards
(237 cards)
What is the purpose of variables?
to store values to be called upon later
how do you declare a variable
using a keyterm (var, let, const)
how do you initialize a variable?
using an equal sign
what characters are allowed in variable names?
$, _, letters (cap and no cap), numbers (cannot start with a number), non keyword (e.g. var), - , .
What does it mean by variables are case-sensitive?
var Cat and var cat are two separate variables
what is the purpose of a string?
to store letters/words/phrases values
what is the purpose of a number?
to store number values
what is the purpose of a boolean
to store true and false values (values that can only be 1 of the 2)
what does the = operator mean in JS?
a value is being assigned to something else
how do you update the value of a variable
assign it a new value
what is the difference between null and undefined?
null is user-defined emptiness, it is intentional and has to be assigned by the programmer (intentional emptiness)
undefined can be assigned by JS to create absence (usually not assigned by programmer)
Why is it a good habit to include labels when you log values to the browser console?
so you know which value you are logging and potentially where to find it
what are objects used for?
used to group similar properties together for ease of calling the values
what are object properties?
Object properties are variables within an object, usually are related or similar to the other properties within an object.
what are two ways to get or update the value of a property?
dot notation and bracket notation
object.property
object[‘property’]
what data type is returned from an arithmetic operation?
numbers
What is string concatenation?
addition for string values
what purpose does the + operator have in JS?
adds two values together
What data type is returned from using comparator operators? (greater than, less than, ===)
boolean (true/false)
what does the += operator do?
takes the existing value of a variable, adds another value to it, then assigns the new value back to it.
what are objects used for?
used for grouping up similar properties with values together for ease of access later
What are arrays used for ?
creating a numbered list of values, number of items within an array can be modified
describe array literal notation
[ value, value, value, value]
how are arrays different from “plain” objects?
arrays have a numbered index, order, and use [ ].