Javascript Flashcards
what is the purpose of variables?
to declare a value.
to store info to be referenced
how do you declare a variable?
using var, let, const keyword
how do you initialize ( assign a value to ) a variable?
add an equal sign and put the value
what characters are allowed in variable names?
No other characters are permitted in the variable name. Specifically, spaces are not permitted in the variable names, as variable name must be a single word. Variable name may not start with a digit or underscore, and may not end with an underscore. Double underscores are not permitted in variable name.
what does it mean to say that variable names are “case sensitive”?
Uppercase and lowercase letters are treated as distinct
what is the purpose of a string?
to store or indicate text value
what is the purpose of a number?
to store or indicate numerical value
what is the purpose of a boolean?
to store or indicate true/false value
what does the = operator mean in javascript?
assigning a value
how do you update the value of a variable?
by assigning a different value that you want
what is the difference between null and undefined?
a null value represents a reference that points, generally intentionally, to a nonexistent or invalid object or address.
undefined is that, there’s no value in it.
why is it a good habit to include “labels” when you log values to the browser console?
to make debugging easier.
Five examples of javascript primitives
string, number, boolean, null, undefined
what data type is returned by an arithmetic operation?
- numeric data type
what is string concatenation?
- connecting strings by using +. combining strings.
- strings are immutable in javascript. (not mutable, it cannot change)
what purpose does the + plus operator serve?
concatenating strings or add numeric values with arithmetic operators.
what data type is returned by comparing two values?
boolean
what does the += plus equals operator do?
add value to the variable and store the value in the same variable
what are objects used for?
JavaScript objects are containers for named values, called properties and methods.
what are object properties?
association between key and value
Describe object literal notation
The Object literal notation is basically an array of key:value pairs, with a colon separating the keys and values, and a comma after every key:value pair, except for the last, just like a regular array.
- opening and closing curly brases
how do you remove a property from an object?
by using the delete keyword
what are the two ways to get or update the value of a property?
adding keys by using dot notation or add inside the object directly.
what are arrays used for ?
it is used for storing different elements