javascript-primitives-and-variable Flashcards
What is the purpose of a variable?
To give permanence to a value
How do you declare a variable?
use the variable keyword var
How do you initialize a variable?
use the var keyword if it hasn’t been declared then have a value on the other side of an equals.
var keyword = swag
What characters are allowed in variable names?
letters, numbers, underscore, dollar sign
What does it mean to say that variable names are case sensitive?
var javaScript is interpreted differently than var javascript
What is the purpose of a string?
It’s a data type that allows you to store all types of characters that JS will not register as code.
What is the purpose of a number?
For mathematical operations
What is the purpose of a boolean?
It’s for decision making. It gives a way to create paths. on or off. if it is do this, if it isnt do this.
What does the = operator mean in JavaScript?
assignment.
How do you update the value of a variable?
var keyword = 6 keyword = 9
What is the difference between null and undefined?
undefined is when a var has not been assigned a value (JS way of saying there is nothing here) and null is a placeholder (also empty, but on purpose).
Why is it a good habit to include “labels” when you log values to the browser console?
organization shortcut
Name 5 examples of JavaScript primitives?
string, number, boolean, undefined, null