JavaScript Flashcards
(174 cards)
What is the purpose of variables?
data storage
How do you declare a variable?
var name;
How do you initialize (assign a value to) a variable?
variable name = variable value;
What characters are allowed in variable names?
letters, numbers, $, underscore
What does it mean to say that variable names are “case sensitive”?
two variables can share the same name but have different capitalization, making them different variables (don’t do this; it’s bad practice)
What is the purpose of a string?
storage of text data
What is the purpose of a number?
storage of numeric data types
What is the purpose of a boolean?
to make decisions
What does the = operator mean in JavaScript?
assignment operator
How do you update the value of a variable?
variable name = new value;
What is the difference between null and undefined?
- null: intentional absence created by a human
- undefined: lack of value recognized by JavaScript
Why is it a good habit to include “labels” when you log values to the browser console?
for clarity and to describe the variable or value being logged
Give five examples of JavaScript primitives
string, number, boolean, null, undefined
What data type is returned by an arithmetic operation?
numeric
What is string concatenation?
adding two or more strings together to create a new string
What purpose(s) does the + plus operator serve in JavaScript?
arithmetic, concatenation
What data type is returned by comparing two values (< , > , ===, etc.)?
boolean
What does the += “plus-equals” operator do?
adds another value to variable and the result of that expression gets assigned to the variable
What are objects used for?
to group together a set of variables and functions
What are object properties?
variables
Describe object literal notation
var object = {
};
How do you remove a property from an object?
by using the delete operator
What are the two ways to get or update the value of a property?
dot notation or bracket notation
What are arrays used for?
store lists of data