Javascript Flashcards
What is the purpose of variables?
It allows you to store data
How do youdeclarea variable?
var keyword with the variable name
How do you initialize (assign a value to) a variable?
use the assignment operator ( = )
What characters are allowed in variable names?
Can start with $, _, or any letter
Cannot start with a number
Cannot use - or .
Cannot use keywords like var
What does it mean to say that variable names are “case sensitive”?
happy and hAppy will be two different variables
What is the purpose of a string?
To provide data as text
What is the purpose of a number?
To provide numeric value for a variable or for calculations
What is the purpose of a boolean?
Give a true or false value
What does the=operator mean in JavaScript?
Assigns a value
How do you update the value of a variable?
you can assign the variable to a new value
What is the difference betweennullandundefined?
Null is intentionally left empty, Undefined is a variable with no value
var apple;
VS.
var apple = undefined;
Why is it a good habit to include “labels” when you log values to the browser console?
It allows you to see if you code is working properly and provides clarity
Give five examples of JavaScript primitives.
Number, string, boolean, null, undefined
What data type is returned by an arithmetic operation?
number
What is string concatenation?
Joining of strings using + operator
What purpose(s) does the+plus operator serve in JavaScript?
Addition or concatenation
Adds one value to anoter
What data type is returned by comparing two values (,===, etc)?
Boolean
What does the+=”plus-equals” operator do?
It adds the value on the right side of the operator to the value of the variable on the left side and reassigns it to the variable on the left side
Var motto = fullName + ‘ is the GOAT’
Motto += ‘ is the GOAT’
What are objects used for?
Storing multiple functions or properties of an item
What are object properties?
key value pairs relating to the defined variable
Describe object literal notation.
A variable is defined
There is the opening curling brace for the code block
Properties made of key value pairs separated by commas
closing curly brace of the code block
Semicolon
How do you remove a property from an object?
delete variable.property
What are the two ways to get or update the value of a property?
Reassign the value of the variable
Create a var.property and have a value assigned to it
What are arrays used for?
It stores a list of values that are related to each other