JavaScript Flashcards
What is the purpose of variables?
to hold values
How do you declare a variable?
var let const
How do you initialize (assign a value to) a variable?
=
What characters are allowed in variable names?
$_ letters and numbers
What does it mean to say that variable names are “case sensitive”?
casing matters
What is the purpose of a string?
for storing and manipulating text
What is the purpose of a number?
math
What is the purpose of a boolean?
to show true or false
What does the = operator mean in JavaScript?
assign
How do you update the value of a variable?
the variable name = new value
What is the difference between null and undefined?
null have a value while undefined does not
Why is it a good habit to include “labels” when you log values to the browser console?
to keep track of what you are logging
Give five examples of JavaScript primitives.
number, string, boolean, null, undefined
What data type is returned by an arithmetic operation?
number
What is string concatenation?
combining 2 strings into one +=
What purpose(s) does the + plus operator serve in JavaScript?
addition
What data type is returned by comparing two values (<, >, ===, etc)?
boolean
What does the += “plus-equals” operator do?
addition -> assignment
What are objects used for?
to store data in an unordered list type structure
What are object properties?
variables, but for objects
Describe object literal notation.
var newObject = { };
How do you remove a property from an object?
delete operator
What are the two ways to get or update the value of a property?
dot or bracket notation
What are arrays used for?
To store data of the same type together in the same place
Describe array literal notation.
[]
How are arrays different from “plain” objects?
they have a numbered index
What number represents the first index of an array?
0
What is the length property of an array?
how long the array is in numbers
How do you calculate the last index of an array?
length of the array - 1
What is a function in JavaScript?
A set of statements that performs a task
Describe the parts of a function definition.
function -> name (parameters) { code -> optional return }
Describe the parts of a function call.
nameOfFunction(arguments);
When comparing them side-by-side, what are the differences between a function call and a function definition?
a function call doesn’t include a code block
What is the difference between a parameter and an argument?
A parameter is a placeholder which will eventually become an argument with a function call
Why are function parameters useful?
Allows functions to perform tasks without knowing the inputs ahead of time.