JavaScript Flashcards
What is the purpose of variables
Used to store (remember) data; short-term memory
How do you declare a variable?
Variable keyword and variable identifier (name)
What characters are allowed in variable names?
Numbers and letters, $, and underscores; numbers cannot be the first character
What does it mean to say that variable names are case sensitive?
Casing all needs to be the same or they are not the same
What is the purpose of a string
Store and manipulate text
What is the purpose of a number
To contain numeric data for calculations
What is the purpose of a Boolean
Represents true or false (binary values) useful for decision making
What does the = operator mean in JavaScript
Assignment operator; assigns a value to a variable
How do you update the value of a variable
Put the variable name again and using the assignment operator you just change the value
What is the difference between null and undefined
Null: represents nothing, something that doesn’t exist (intentional nothing put by the programmer)
Undefined: something isn’t there
Why is it good habit to include “labels” when you log values to the browser console
It’s more clear to see what data is being logged to the console and is a helpful debugging tool
Give five examples of JavaScript primitives
String, number, Boolean, undefined, null
What data type is returned by an arithmetic operation
Number
What is string concatenation
Two or more strings joined together to make a single string
What purpose(s) does the + plus operator serve in JavaScript
Addition or concatenation
What data type is returned by comparing two values
Boolean
What does the += “plus-equals” operator do
Addition assignment; adds a value then updates the variable
What are objects used for
Used to group together sets of variables and functions that have some relation to each other (can include functionality) to model or represent something
What are object properties
They are variables used within an object
Describe object literal notation
Curtly braces: sets of key-value pairs (property or method and it’s value separated by a colon) and the key-value pairs which are separated by commas except for the last one
How do you remove a property from an object
Delete keyword followed by name of the object, member operator (.), and name of property or method you want to delete
What are two ways to get or update the value of a property
Dot notation: object.property/method
Bracket notation: object[property/method]
What are arrays used for
Storing lists of values related to each other
Describe array literal notation
Data separated by commas within square brackets