JavaScript Flashcards
(306 cards)
What is the purpose of variables?
To temporarily store bits of information a script needs to do its job
How do you declare a variable?
set a variable name to a variable keyword like var
How do you initialize (assign a value to) a variable?
set a value to the variable name with an assignment operator = < > …
What characters are allowed in variable names?
letters, dollar sign or underscore, it cannot start with a number
What does it mean to say that variable names are “case sensitive”?
capitalization matters
What is the purpose of a string?
strings are data types that consist of letters and other characters, enclosed in quotes, frequently used to add new content to a page
What is the purpose of a number?
for numeric data and counting, calculating sums, measurements, time, etc.
What is the purpose of a boolean?
to indicate whether something is true or false
What does the = operator mean in JavaScript?
the equals operator assigns a value to a variable
How do you update the value of a variable?
use the variable name and equals sign to assign it a new value
What is the difference between null and undefined?
without setting a variable name to a variable keyword, the name will be null, without assigning a value to a variable, it will be undefined.
null is a nonexistent or invalid object
Why is it a good habit to include “labels” when you log values to the browser console?
to help you debug code, so you know which variable is being logged
Give five examples of JavaScript primitives.
null, string, number, boolean, undefined, symbol, bigint
What data type is returned by an arithmetic operation?
an expression?
What is string concatenation?
combining two strings into one
What purpose(s) does the + plus operator serve in JavaScript?
concatenation, addition, forcing a variable into a number, incrementing by one for a double plus
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
addition assignment, total += 1 would mean total = total + 1
What are objects used for?
storing multiple properties related to a variable
What are object properties?
variables that tell us about the object
Describe object literal notation.
an object’s properties and methods are assigned a variable name with the equals operator
How do you remove a property from an object?
delete object name . property name
What are the two ways to get or update the value of a property?
dot notation or square bracket with property in quotes
What are arrays used for?
a list of values that are related to each other