Javascript Flashcards
(225 cards)
What is the purpose of variables?
To store some sort of value
How do you declare a variable?
var varName = value;
How do you initialize (assign a value to) a variable?
varName = newValue;
What characters are allowed in variable names?
Letters, numbers, underscore, $dollar_sign
What does it mean to say that variable names are “case sensitive”?
“THIS” is different from “this” and “tHiS”
What is the purpose of a string?
To represent letters and characters
What is the purpose of a number?
To represent numerical data
What is the purpose of a boolean?
Used as a trigger for a condition
What does the = operator mean in JavaScript?
It’s the assignment operator
How do you update the value of a variable?
Assign a new value on the right side of the = operator
What is the difference between null and undefined?
null points to a nonexistent address
Undefined is a value for variables not yet defined
Why is it a good habit to include “labels” when you log values to the browser console?
It helps you recognize why you are logging onto the console
Give five examples of JavaScript primitives.
Number, string, boolean, array, object
What data type is returned by an arithmetic operation?
number
What is string concatenation?
Joining two or more strings together
What purpose(s) does the + plus operator serve in JavaScript?
String concatenation, addition for numbers
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
Adds the given value and re-assigns the new value to the variable on the left hand side of the operator
What are objects used for?
A data type that groups together a set of variables and functions to model real life ‘objects’
What are object properties?
Variables that hold data unique to that object
Describe object literal notation.
Declared with var objName = { }; Properties are stored between curly braces separated by commas
How do you remove a property from an object?
delete obj.prop;
What are the two ways to get or update the value of a property?
Dot notation and bracket notation with assignment operator
What are arrays used for?
To store related data in an ordered list