JavaScript Flashcards
What is the purpose of variables?
Javascript-primitives-and-variables
To store information/data.
How do you declare a variable?
Javascript-primitives-and-variables
You write var, let, or const; the name of the variable; and an assignment operator.
How do you initialize (assign a value to) a variable
Javascript-primitives-and-variables
You use an equal sign
What characters are allowed at the start of variable names?
Javascript-primitives-and-variables
$, underscore, and letters.
What does it mean to say that variable names are “case sensitive”?
(Javascript-primitives-and-variables)
A variable with a capital is different than a variable without one.
What is the purpose of a string?
Javascript-primitives-and-variables
To store text content data.
what is the purpose of a number?
Javascript-primitives-and-variables
For data that needs numbers.
What is the purpose of a boolean?
Javascript-primitives-and-variables
To give us a choice between true or false.
What does the = operator mean in JavaScript
Javascript-primitives-and-variables
It means assignment operator.
How do you update the value of a variable?
Javascript-primitives-and-variables
You assign the variable a different value.
What is the difference between null and underfined?
Javascript-primitives-and-variables
Null is for values that the coder can change later.
Undefined could be on an accident
Why is it a good habit to include “labels” when you log values to the browser console?
(Javascript-primitives-and-variables)
To prevent confusion
Give five examples of JavaScript primitives.
Javascript-primitives-and-variables
String, array, object, integer, boolean, null, undefined.
What data type is returned by an arithmetic operation?
Javascript-operators-and-expressions
Numbers.
What is string concatenation?
Javascript-operators-and-expressions
The joining of two or more strings together using the plus operator.
What purpose(s) does the + plus operator serve in JavaScript (Javascript-primitives-and-variables)
It adds numbers and joins strings together.
What data type is returned by comparing two values (, ===, etc)?
(Javascript-operators-and-expressions)
A boolean.
What does the += operator do?
Javascript-operators-and-expressions
It adds the variable and anything else and assigns the result of the expression to that variable.
What are objects used for?
Javascript-objects
Store related info for easy access later
What are object properties?
Javascript-objects
They are attached to objects to define their characteristics.
Describe object literal notation.
Javascript-objects
Curly-braces , {}
How do you remove a property from an object?
Javascript-objects
Use the delete operator on the property of the object.
What are the two ways to get or update the value of a property?
(Javascript-objects)
By using the dot method and giving it a different value or changing it in the object literal.
What are arrays used for?
Javascript-arrays
Storing related information in a specific order.