JavaScript Foundations Flashcards
What is the purpose of variables?
To store values
How do you declare a variable?
‘var varName’
How do you initialize (assign a value to) a variable?
var varName = ‘assignedValue’
What characters are allowed in variable names?
letters, _, $
And after first letter: numbers, letters, _, $
What does it mean to say that variable names are “case sensitive”?
var varName is different from var varname
What is the purpose of a string?
To store a value that contains any characters
What is the purpose of a number?
Used to manipulate numbers/do math
What is the purpose of a boolean?
Create logic in a JavaScript file. Sets up true/false values
What does the = operator mean in JavaScript?
It is used as a way to assign values to variables
How do you update the value of a variable?
Either declare it again or edit the value where the variable was declared earlier
What is the difference between null and undefined?
Null means it is defined but intentionally missing a value
Undefined means it isn’t defined and it doesn’t exist
Why is it a good habit to include “labels” when you log values to the browser console?
For readability/communication for those reading the code
Give five examples of JavaScript primitives.
Undefined Null Boolean String Number
What data type is returned by an arithmetic operation?
Number
What is string concatenation?
‘string’+’string’ which combines the strings together