javascript-primitives-and-variables Flashcards
What is the purpose of variables?
Variables are used to store information to be referenced and manipulated in a computer program.
How do you declare a variable?
- var
- let
- const
How do you initialize (assign a value to) a variable?
The (=) assignment operator is used to initialize a variable.
What characters are allowed in variable names?
Variable names can only contain letters, numbers, underscores, or dollar signs.
Variable names must begin with a letter, an underscore (_) or a dollar sign ($).
What does it mean to say that variable names are “case sensitive”?
Variable names must always be typed with a consistent capitalization of letters.
What is the purpose of a string?
It is used to represent text.
What is the purpose of a number?
It is used to represent numbers.
What is the purpose of a boolean?
It is used to represent true or false statements.
What does the = operator mean in JavaScript?
It is the assignment operator.
How do you update the value of a variable?
Use the variable name, the equals sign (also known as the assignment operator), and the new value for that attribute.
What is the difference between null and undefined?
Undefined means a variable has been declared but has not yet been assigned a value. … On the other hand, Null is assigned to a variable as a representation of no value.
Why is it a good habit to include “labels” when you log values to the browser console?
Labels add clarity.
Give five examples of JavaScript primitives.
- string
- number
- boolean
- null
- undefined
- bigint
- symbol