Javascript-primitives-and-variables-Q&A Flashcards
What is the purpose of variables?
To store information
How do you declare a variable?
Use 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”?
It means that variables with capital and lowercase letters are different I.E. var variable = x var Variable = y
What is the purpose of a string?
String is 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?
Assignment
How do you update the value of a variable?
Reference 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?
So you know what youre looking at
Give five examples of JavaScript primitives.
Number, string, boolean, undefined, null