JavaScript Flashcards
What is the purpose of variables?
To store data
How do you declare a variable?
variable key word let var or const and variable name operator then value
How do you initialize (assign a value to) a variable?
assignment operator value
What characters are allowed in variable names?
must begin with letter, $, _ cannot use (.) or dash. cannot use key words reserved for words. All variables are case sensitive. Bad practice to use same name using different cases.
What does it mean to say that variable names are “case sensitive”?
It has to match; and you use camelcase to make sure that is the case
What is the purpose of a string?
store and manipulate text
What is the purpose of a number?
store numbers
What is the purpose of a boolean?
Booleans are helpful when
determining which part of a
script should run.
What does the = operator mean in JavaScript?
it assigns a value
How do you update the value of a variable?
You don’t need to use the variable keyword you use the variable name.
What is the difference between null and undefined?
Null is a non-existent or invalid object or address.
whereas undefined has been just assigned
Why is it a good habit to include “labels” when you log values to the browser console?
It describes the variable that is being entered and if you don’t put it it can be very confusing when reading your logs.
Give five examples of JavaScript primitives.
null, string, bigint, boolean, undefined, symbol and null
What data type is returned by an arithmetic operation?
Number
What is string concatenation?
Process of joining together two or more strings to create one new string
What purpose(s) does the + plus operator serve in JavaScript?
to perform addition or string concatenation
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
adds the value on the right, to the variable on the left, and then assigns that value back into the variable on the left.
What is an expression
Junk of work that JavaScript needs to do
What are objects used for?
THere used to group together a set of variables and functions.
What are object properties?
it is a variable that is now a part of the object
Describe object literal notation.
variable object = { key: value}
How do you remove a property from an object?
you use the key word delete and then use dot notation to identify the property or method you want to remove from the object.
What are the two ways to get or update the value of a property?
use dot notation or square brackets