Module 1 Javascript Flashcards
(147 cards)
What is the purpose of variables?
It tells the script to store information to be used again later.
How do you declare a variable?
declare var, let, or const. Can be declared undefined or can have value assigned initially.
How do you initialize (assign a value to) a variable?
Use equal sign =
What characters are allowed in variable names?
Must start with any letter, dollar sign $, or underscore _, numbers as long as it is not the first letter, no - or .
What does it mean to say that variable names are “case sensitive”?
Capitalization matters in variable name
What is the purpose of a string?
String stores a series of letters or other characters, used for adding text.
What is the purpose of a number?
Store numerical values.
What is the purpose of a boolean?
Booleans store a true or false value.
What does the = operator mean in JavaScript?
single equal sign = is for assigning values.
How do you update the value of a variable?
state variableName = newValue; Reassign, not redeclare.
What is the difference between null and undefined?
Null represents an nonexistend or invalid object. Undefined means nothing has been declared or assigned, so there is nothing, not even an object.
Why is it a good habit to include “labels” when you log values to the browser console?
Helps you debug so you know at which step and for what reason the console is logged.
Give five examples of JavaScript primitives.
string, number, boolean, null, undefined.
What data type is returned by an arithmetic operation?
A number
What is string concatenation?
Combining two or more strings into one string. Numbers concatenated with strings also become a string.
What purpose(s) does the + plus operator serve in JavaScript?
It can both add numbers as an operator and concatenate strings.
What data type is returned by comparing two values (, ===, etc)?
Boolean
What does the += “plus-equals” operator do?
Adds the value to the right and assigns it to the variable on the left.
What are objects used for?
Grouped set of property variables to create a model of a real world object.
What are object properties?
The variables within the object
Describe object literal notation.
the object name is being declared and assigned with opening curly brace, within are key values and property pairs separated by commas, and closing curly brace.
How do you remove a property from an object?
Use delete keyword and call out the object property using either dot or bracket notation.
What are the two ways to get or update the value of a property?
Name the object property using either dot or bracket notation, and assign a new value if desired.
What are arrays used for?
To have an ordered list of items