javascript-primitives-and-variables Flashcards
What is the purpose of variables?
To store data for future reference or usage by the computer
How do you declare a variable?
Using the keyword var, let or const
How do you initialize (assign a value to) a variable?
Using the equal sign operator
What characters are allowed in variable names?
Dollar, underscore or numbers.
What does it mean to say that variable names are “case sensitive”?
It means adding a capital letter or small letter to any part of the variable name even if the word spells the same is not the same.
What is the purpose of a string?
Strings are a type of data that contain alphanumeric words, they help to tell the computer what kind of data they are processing.
What is the purpose of a number?
Numbers are used to store numeric data
What is the purpose of a boolean?
Booleans are a certain data type that always return one of two values either true or false.
What does the = operator mean in JavaScript?
To assign a value to a variable
How do you update the value of a variable?
By declaring its name and assigning it a new value
What is the difference between null and undefined?
Null is intentionally nothing, undefined is a variable declared but not assigned any value.
Why is it a good habit to include “labels” when you log values to the browser console?
It helps with debugging
Give five examples of JavaScript primitives.
Null, Boolean, Number, String, Object, Undefined