JavaScript Flashcards
What is the purpose of variables?
to store data
How do you declare a variable?
you the keyword var and then the variable name
How do you initialize (assign a value to) a variable?
=
What characters are allowed in variable names?
letters, numbers, underscore, $
What does it mean to say that variable names are “case sensitive”?
upper case letters and lower case letters are different
What is the purpose of a string?
to hold a list of characters
What is the purpose of a number?
they are for math
What is the purpose of a boolean?
to return the value true or false
What does the = operator mean in JavaScript?
its an assignment operator
How do you update the value of a variable?
you put the variable name and = then the new value
What is the difference between null and undefined?
null means the variable has no value and undefined refers to a value that is empty or doesn’t exist
Why is it a good habit to include “labels” when you log values to the browser console?
to show what is being used
Give five examples of JavaScript primitives.
number, undefined, string, boolean, null
What data type is returned by an arithmetic operation?
Number
What is string concatenation?
When two or more strings are joined together to create one new string
What purpose(s) does the + plus operator serve in JavaScript?
It adds numbers together or concatenates strings
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 to the left variable
What are objects used for?
Grouping together a set of variables and functions to create a model of something you would recognize from the real world.
What are object properties?
A variable within an object.
Describe object literal notation.
declare the variable and name it then use curly brace and make property and value
How do you remove a property from an object?
delete object.property
What are the two ways to get or update the value of a property?
dot notation and bracket notation
What are arrays used for?
Storing multiple pieces of data