JavsScript Flashcards
(139 cards)
What is the purpose of variables?
-Store data for a script to do its job
How do you declare a variable?
-var
How do you initialize (assign a value to) a variable?
-By using the assignment operator
What characters are allowed in variable names?
-Letters, numbers, dollar signs, underscore
What does it mean to say that variable names are “case sensitive”?
-Score and score are different variable names
What is the purpose of a string?
-String type data consists of letters and other characters
What is the purpose of a number?
-Numeric data type handle number quantities
What is the purpose of a boolean?
-Boolean data types can have one of two values: true or false.
What does the = operator mean in JavaScript?
-Assign a value to the variable
How do you update the value of a variable?
-By using the assignment operator
What is the difference between null and undefined?
-null is an intentionally assigned value to a nonexistent or invalid object, undefined means a variable has been declared but not defined yet
Why is it a good habit to include “labels” when you log values to the browser console?
-A console log “label” is simply a short string that describes the variable or value being logged
Give five examples of JavaScript primitives.
-There are 7 primitive data types: string, number, bigint, boolean, undefined, symbol, and null
What data type is returned by an arithmetic operation?
-Single numerical value
What is string concatenation?
-Concatenate is a fancy programming word that means “join together”
What purpose(s) does the + plus operator serve in JavaScript?
-The addition operator produces the sum of numeric operands or string concatenation
What data type is returned by comparing two values (, ===, etc)?
-Boolean
What does the += “plus-equals” operator do?
-The addition assignment operator adds the value of the right operand to a variable and assigns the result to the variable.
What are objects used for?
-Objects group together a set of variables and functions
What are object properties?
-Variables that are part of an object
Describe object literal notation.
- Object is the curly braces and their contents
- Separate each key from its value using a colon
- Separate each property and method with a comma (not after the last value)
How do you remove a property from an object?
- delete object.property
- delete object[‘property’]
What are the two ways to get or update the value of a property?
-dot notation or square bracket syntax
What are arrays used for?
-Storing lists of values that are related to each other