JavaScript Flashcards
What is the purpose of variables?
to be able to store and reference data
How do you declare a variable?
use the keyword var with its name
How do you initialize (assign a value to) a variable?
use =
What characters are allowed in variable names?
anything but cannot start with a number or a be a keyword
What does it mean to say that variable names are “case sensitive”?
capital letters are not the same as lowercase letters
What is the purpose of a string?
to store words into javascript
What is the purpose of a number?
used for counting and arithmetic
What is the purpose of a boolean?
to state yes or no within javascript
What does the = operator mean in JavaScript?
assign to
How do you update the value of a variable?
use the assign to and value
What is the difference between null and undefined?
null is empty on purpose. Undefined is nothing is defined (usually accident)
Why is it a good habit to include “labels” when you log values to the browser console?
So console can be organized and easier to read
Give five examples of JavaScript primitives.
String, Number, Boolean, Null, Underfined
What data type is returned by an arithmetic operation?
a number
What is string concatenation?
combining strings
What purpose(s) does the + plus operator serve in JavaScript?
add or concatenation
What data type is returned by comparing two values (, ===, etc)?
Boolean
What does the += “plus-equals” operator do?
take the variable and update value
What are objects used for?
a box to keep related stuff together
What are object properties?
exclusive variables for an object
How do you remove a property from an object?
Use the delete operator (ex: delete person.firstName)
What are the two ways to get or update the value of a property?
dot notation or with brackets
What is a function in JavaScript?
group of actions that are repeatable
Describe the parts of a function definition.
keyword function, function name, ( ) with parameaters if there are any, { }, return
Describe the parts of a function call.
the function name with ( ) including paramethers inside, if any
When comparing them side-by-side, what are the differences between a function call and a function definition?
definition has keyword function and { }, calling does not
What is the difference between a parameter and an argument?
parameter are a placeholder until arguments are sent in
Why are function parameters useful?
allows us to change the value of the variables being sent through the function
What two effects does a return statement have on the behavior of a function?
return stops function from running and returns the value to the outside of the function
What are arrays used for?
store a list of values (strings, numbers, boolean, objects)
Describe array literal notation.
var = [ ] using brackets
How are arrays different from “plain” objects?
arrays use an index while objects use keywords to organize data
What number represents the first index of an array?
0
What is the length property of an array?
the number of elements in the array
How do you calculate the last index of an array?
array.length - 1
Why do we log things to the console?
to follow the the code and for other developers to read
What is a method?
a function that is a proporty of an object
How is a method different from any other function?
syntax; with a method you must provide which object its connected to
How do you remove the last element from an array?
_____.pop()
How do you round a number down to the nearest integer?
Math.floor()
How do you generate a random number?
Math.random( )
How do you delete an element from an array?
splice( start_index , how_many , replace? )
How do you append an element to an array?
splice( start_index , how_many , replace? )
How do you break a string up into an array?
___.split( )
Do string methods change the original string? How would you check if you weren’t sure?
No, try it out or read some documentation
Is the return value of a function or method useful in every situation?
It does not need to be utilized in every instance
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN
Give 6 examples of comparison operators.
=== , !== , > , < , <= , >=
What data type do comparison expressions evaluate to?
boolean
What is the purpose of a loop?
check a condition, more than once
What is the purpose of a condition expression in a loop?
to make the code run or stop the code