Javascript-Primitives-and-Variables Flashcards
What is the purpose of variables?
Variables are used to store data
How do you declare a variable?
You use a variable keyword like var followed by creating a variable name
How do you initialize (assign a value to) a variable?
Use the assignment operator which is an = sign
What characters are allowed in variable names?
Numbers, Letters, dollar sign $, and underscore _
What does it mean to say that variable names are “case sensitive”?
If two variables with the same name start with different case types, then they will become different variables.
What is the purpose of a string?
Strings can be used as a data type related to text.
What is the purpose of a number?
Numbers can be used as a data type when a numerical value needs to be stored.
Used for calculating.
What is the purpose of a boolean?
A boolean data type can be used to determine if something is true or false.
What does the = operator mean in JavaScript?
It is the assignment operator that assigns a data value to a variable name
How do you update the value of a variable?
Use the assign operator to assign an updated value to the variable name.
What is the difference between null and undefined?
A null data type assigned to a variable is purposefully empty and undefined data type indicates that the variable does not have a value assigned to it.
Why is it a good habit to include “labels” when you log values to the browser console?
Including labels helps you understand the variable value being logged by supplying a brief description
Give five examples of JavaScript primitives.
String, Number, Boolean, Null, Undefined