JavaScript Basics Flashcards
What is the purpose of variables?
To store and re-use data
How do you declare a variable?
Using the var, const, or let keyword followed by the name of the variable
How do you initialize (assign value to) a variable?
Using the var, const, or let keyword followed by the name of the variable followed by an assignment operator followed by a value
What characters are allowed in variable names?
Letters, numbers, period, underscore, dollar sign
The first character of a variable name cannot be a number
What doesit mean to say that variable names are “case sensitive”?
You can only use the exact matching name of a variable as a value for anything
What is the purpose of a string?
Allows you to create strings of characters
What is the purpose of a number?
It allows you to hold numeric value and perform calculations
What is the purpose of a boolean?
To use True or False values, such as conditionals
What does the = operator mean in JavaScript?
It’s the assignment operator
How do you update the value of a variable?
Without declaring the variable, assign the variable a new value
What is the difference between null and undefined?
Undefined means a value does not exist
Null is an assigned value that was used intentionally
Why is it a good habit to include “labels” when you log values to the browser console?
It makes debugging easier when you know the value of what variable the console.log is returning
Give five examples of JavaScript primitives
String, number, boolean, null, undefined
What data type is returned by an arithmetic operation?
Numeric value
What is string concatenation?
Combining two or more string values