JavaScript Flashcards
(126 cards)
What is the purpose of variables?
Gives us a way to call data later
How do you declare a variable?
var varName;
How do you initialize (assign a value to) a variable?
Set the variable equal to the desired value var varName = value;
What characters are allowed in variable names?
Any number, letter, _ , or $
But they must start with a letter, underscore (_), or $
What does it mean to say that variable names are “case sensitive”?
You must capitalize the variable’s spelling the same, in order to use it
var weTall is not the same as var wetall
What is the purpose of a string?
Stings are the form of data that allow you to enter a chain of text.
What is the purpose of a number?
Numbers are used for calculations and placement
What is the purpose of a boolean?
Booleans are true and false
They are used to decide whether an action should be taken or not
What does the = operator mean in JavaScript?
It assigns a value to a variable
The assignment operator
How do you update the value of a variable?
Set it equal to a different value, lower in the code var name = 'old name'; name = 'new name';
What is the difference between null and undefined?
Null means the items do not exist yet. Its data type is an object which was defined by a developer intentionally.
Undefined means the variable has not been given a value yet. Its data type undefined.
Why is it a good habit to include “labels” when you log values to the browser console?
You can know, in the console, what you are logging and make sure you are referring to the correct data.
Give five examples of JavaScript primitives.
Numbers String Boolean Null undefined
What data type is returned by an arithmetic operation?
numbers
arithmetic: involving numbers (numeric)
What is string concatenation?
Adding two or more strings to make one new, larger string
‘Sting’ + ‘ adding’ = ‘Strings adding’
What purpose(s) does the + plus operator serve in JavaScript?
Adding numbers together
Concatenating strings
What data type is returned by comparing two values (, ===, etc)?
Booleans
True or false
What does the += “plus-equals” operator do?
+=: addition assignment operator
Adds the item on the right, to the item on the left. THEN it replaced the item on the left with the new value
What are objects used for?
Give us a way to collect our data into smaller groups
What are object properties?
The items within an object. Keys & their values
Describe object literal notation.
var varName = {
property: value,
property: 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: object.property = x
Bracket notation: object[‘property’] = x
What are arrays used for?
To make a series of data you can tie to a specific number
When you dont know how many pieces of that data you need
Groups of data that have the same type of data