Javascript-primitives-and-variables Flashcards
What is the purpose of variables?
To store information/data
How do you declare a variable?
Use a keyword(like var) followed by a variable name.(also called identifier.)
How do you initialize (assign a value to) a variable?
With a assignment operator “=” followed by variable value.
What characters are allowed in variable names?
letter, dollar sign, underscore.
What does it mean to say that variable names are “case sensitive”?
A lowercase variable name will be different if the first letter is capitalized.
What is the purpose of a string?
It can be used for any kind of text.
What is the purpose of a number?
It can be used on tasks that involve counting or calculating.
What is the purpose of a boolean?
To represent a truthy or falsey value.
What does the = operator mean in JavaScript?
To assign a value.
How do you update the value of a variable?
Re-assign a value to that variable.
What is the difference between null and undefined?
Null means it’s a falsy value that is preset by the programmer for a specific purpose, undefined means the variable hasn’t been assigned a value.
Why is it a good habit to include “labels” when you log values to the browser console?
to add clarity to the output.
Give five examples of JavaScript primitives.
string, number, boolean, undefined, null.