JavaScript Flashcards
(110 cards)
What is the purpose of variables?
to store data and use it later
How do you declare a variable?
by putting var ____ < name
How do you initialize (assign a value to) a variable?
use the equal operator it represents the word “assignment”
What characters are allowed in variable names?
lowercase, numbers, dollar sign, underscore. No dash(-) or (.), also do not start with a number. Start with either a letter, dollar sign, or underscore
What does it mean to say that variable names are “case sensitive”?
score and Score are considered different variables (DO NOT DO THIS)
What is the purpose of a string?
To write characters and words
What is the purpose of a number?
To give data
What is the purpose of a boolean?
It is an on off switch that can be used to determine whether something should run in a script
What does the = operator mean in JavaScript?
it means assignment
How do you update the value of a variable?
The var keyword isn’t necessary but you simply reassign it later in the document.
What is the difference between null and undefined?
null is an intentional way of saying nothing, undefined is the way the computer says nothing. Every null value you see is purposeful.
Why is it a good habit to include “labels” when you log values to the browser console?
Labels provide clarity for other people and for you in the future.
Give five examples of JavaScript primitives.
string, number, boolean, null, undefined
What data type is returned by an arithmetic operation?
numeric data type, some sort of number
What is string concatenation?
string concatenation is taking two strings together and gluing them to make a new string
What purpose(s) does the + plus operator serve in JavaScript?
arithmetic operations, string operations (concatenating)
What data type is returned by comparing two values (, ===, etc)?
boolean data types
What does the += “plus-equals” operator do?
it’s shorthand
motto+= ‘is the goat’;
motto=motto + ‘is the goat’;
they are the same, the way you read the second line is what the first one is doing
What are objects used for?
objects group together variables and functions
What are object properties?
Object properties are keys and values
Describe object literal notation.
object literals itself is the curly braces
How do you remove a property from an object?
use the delete operator object.property
What are the two ways to get or update the value of a property?
bracket notation and dot notation
anything that follows the dot notation is a string
bracket notation lets you check for an expression when accessing a property
What are arrays used for?
a list or a set of values related to each other. Especially useful if you aren’t sure how big the list will be. Also the keys are indexed automatically with a number.