JavaScript Flashcards
What is the purpose of variables?
Variables are used to represent values/store information that can be used in your code.
How do you declare a variable?
by using the keyword var followed by a name to represent your variable.
How do you initialize (assign a value to) a variable?
By using the assignment operator followed by a value
What characters are allowed in variable names?
letters, numbers, dollar signs, or underscores. However, the name can NOT start with a number
What does it mean to say that variable names are “case sensitive”?
variables names are sensitive to the capitalization of letters. Example: var keyword and var keyWord are two different variables.
What is the purpose of a string?
a string is a data. type that is represented using characters and text.
What is the purpose of a number?
a number is a data type represented by numbers and is used for calculating values. Used to store numeric values.
What is the purpose of a boolean?
a boolean is a data type that only has two values: true and false. Good for logical reasoning
What does the = operator mean in JavaScript?
assignment operator. assigns values to avaraibles
How do you update the value of a variable?
by taking the variable name and assigning it a new value with he assignment operator, So long as this line of code comes after the initial value assignment.
What is the difference between null and undefined?
null is intentionally assigned an empty value and its type is an object, whereas undefined can be unintentional and means a variable has been declared but not assigned a value yet.
Why is it a good habit to include “labels” when you log values to the browser console?
So you know what variable/information you are logging to the console.
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 into one variable using + operator
What purpose(s) does the + plus operator serve in JavaScript?
addition or concatenation
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
adds a value to the variables original value.
What are objects used for?
objects are used for storing multiple values.
What are object properties?
object properties are variables that are stored within an object.
Describe object literal notation.
object literal notation involves a set of curly braces holding a comma separated list of properties and methods to which is being stored in a variable.
How do you remove a property from an object?
by using the delete operator(keyword) on the object
What are the two ways to get or update the value of a property?
dot notation and bracket notation.
What are arrays used for?
For storing lists of data