javascript-primitives-and-variables Flashcards
What is the purpose of variables?
Variables are used to store information.
How do you declare a variable?
You declare a variable by using the reserved keyword var to declare a variable in JavaScript.
How do you initialize (assign a value to) a variable?
The way of initializing a variable is very similar to the use of PARAMETER attribute. More precisely, do the following to initial a variable with the value of an expression: add an equal sign (=) to the right of a variable name. to the right of the equal sign, write an expression.
What characters are allowed in variable names?
The period, the underscore, and the characters $, #, and @ can be used within variable names.
What does it mean to say that variable names are “case sensitive”?
"Case sensitive" variables mean that variables with capital and lowercase letters are different EX: var variable = x var Variable = y var Variable = y
What is the purpose of a string?
Strings are a primitive data type in JavaScript. A string is textual content.
What is the purpose of a number?
Number is a primitive wrapper object used to represent and manipulate numbers
What is the purpose of a boolean?
Boolean refers to a system of logical thought that is used to create true/false statements.
What does the = operator mean in JavaScript?
The “=” operator means assignments in Javascript.
How do you update the value of a variable?
You can update the value of the variable by referencing the variable inside the function.
What is the difference between null and undefined?
Null:
It is the intentional absence of the value. It is one of the primitive values of JavaScript.
Undefined:
It means the value does not exist in the compiler.
Why is it a good habit to include “labels” when you log values to the browser console?
It’s a good habit to include labels when you log values to the browser console because it helps you know what you’re looking at.
Give five examples of JavaScript primitives.
Five examples of Javascript primitives:
- Number
- String
- Boolean
- Undefined
- Null