JavaScript Primitives, Variables, Objects, and Arrays Flashcards
What is the purpose of variables?
To store data that can be referenced later in your code
How do you declare a variable?
var/let/const varName = data type
vet/let/const followed by varName followed by the assignment operator followed by the datatype
How do you initialize (assign a value to) a variable?
var varName = varValue/Data
You use the assignment operator
What characters are allowed in variable names?
Names can contain letters, digits, underscores, and dollar signs
What does it mean to say that variable names are “case sensitive”?
To call the value of a variable, you must type the name exactly as you did when you declared the value to the name of the variable
camelCase
What is the purpose of a string?
They are used to add new content into a page and they can contain markup
It’s a way to store data we can pass around
What is the purpose of a number?
A number is used mainly for calculations
These store numeric values
What is the purpose of a boolean?
They help determine which part of the script should run
True or False
What does the = operator mean in JavaScript?
It is an assignment operator
It is saying you are going to assign a value to the variable
What is the difference between null and undefined?
Undefined means it has an empty value
Null is an empty value but it was put there for a reason
Why is it a good habit to include “labels” when you log values to the browser console?
It describes the variable or the value being logged
It is used for clarity - Labels help understand where and what the value is for
Give five examples of JavaScript primitives.
Undefined, null, boolean, string, number
What data type is returned by an arithmetic operation?
Arithmetic Operators are used for basic math
The data type returned would be number
What is string concatenation?
String Concatenation is where you combine strings
‘Hello’ + ‘ ‘ + ‘World’ = Hello World
Two separate strings get glued together
What data type is returned by comparing two values (, ===, etc?)
A boolean datatype is returned
True -or- False