Javascript Flashcards
What is the purpose of variables?
to store date, to call upon the value later.
How do you declare a variable?
you would write the var then variable name , or identifier. If it has more than one name, it is written in camelCase
[var name:]
How do you initialize (assign a value to) a variable?
you would write the identifier then the variable value;
[name = 420;]
What characters are allowed in variable names?
letters,numbers, dollar sign($) or and underscore.
What does it mean to say that variable names are “case sensitive”?
It needs to be written exactly how it is typed. meaning
thisVariable is not the same as thisvariable
What is the purpose of a string?
to give values that contain letters or other characters.
What is the purpose of a number?
to give a numerical value to a variable. Normally for it use as counting/mathematics.
What is the purpose of a boolean?
to define the var as a true/false value.
What does the = operator mean in JavaScript?
it is the assignment operator. it gives us the ability to assign a value to the variable.
How do you update the value of a variable?
you reassign the variable. you wont need to use the var to reassign the variable.
What is the difference between null and undefined?
null is an intentionally nonexistent or invalid object, while undefined has no given value at all, or unintentional.
Why is it a good habit to include “labels” when you log values to the browser console?
It helps identify what the value is related to, if there is no tag. It will just give out the string/value with no context.
Give five examples of JavaScript primitives
String, number, boolean, undefined, and null.
What data type is returned by an arithmetic operation?
a number value
What is string concatenation?
to join to variables into one.
var fullName = firstName + lastName;
What purpose(s) does the + plus operator serve in JavaScript?
It is used to add one value to another
What data type is returned by comparing two values (, ===, etc)?
boolean; true or false
What does the += “plus-equals” operator do?
It lets us add two values together, the result will then be assigned.
What are objects used for?
Objects are for RELATED data.
What are object properties?
A key value pair, a piece of data that is attached under an object with a unique name. The value may change, but the name will stay the same.
Describe object literal notation
You need { }, to store value, you need property name:(value)
How do you remove a property from an object?
use the delete
What are the two ways to get or update the value of a property?
use dot notation or bracket notation.
dot
object.property = (new value);
bracket
object[‘property’] = (new value);
Describe array literal notation.
a variable will x amount of values separated by commas (usually in the same line)
you can store strings, numbers, and booleans