Primivites and Variables Flashcards
What is the purpose of variables?
Stores data or value to be calculated or computed.
How do youdeclarea variable?
var keyword - var name;
How do you initialize (assign a value to) a variable?
var varname= value
What characters are allowed in variable names?
letters, numbers dollar sign or underscore
What does it mean to say that variable names are “case sensitive”?
Capitalizations matter i.e camel case
What is the purpose of a string?
frequently used to add new content into a page, can contain HTML markup
What is the purpose of a number?
used for tasks to determine size position or setting timers for elements.
What is the purpose of a boolean?
determines which part of a script should run
What does the=operator mean in JavaScript?
assignment operator, updates the value given to a variable
How do you update the value of a variable?
using the assignment operator
What is the difference betweennullandundefined?
undefined is primitive value assigned to variables that have just been declared or to formal arguments where there are no actual arguments. Null is also primitive, every object is derived from null value and typeof returns an object, even though it generally represents a nonexistent or invalid object or address.
Why is it a good habit to include “labels” when you log values to the browser console?
let’s you be explicit with values to make it easier to find problems
Give five examples of JavaScript primitives.
string, number, boolean, valueof, null, undefined