JavaScript Flashcards
What is the purpose of variables?
to see data from the past and preserve for the future (store and organize data)
How do you declare a variable?
var, let, or const
How do you initialize (assign a value to) a variable?
use equal sign assignment operator
What characters are allowed in variable names?
letters, underscore, dollarsigns, and numbers (cannot be first letter)
What does it mean to say that variable names are “case sensitive”?
casing matters (N and n matter when calling a variable)
What is the purpose of a string?
gives a variable a text value that is not code
what is the purpose of a number?
can give numerical values that mostly is used for math
What is the purpose of a boolean?
compare values using true or false
What does the = operator mean in JavaScript?
assigns a value
How do you update the value of a variable?
assign a new value using the equal operator
What is the difference between null and undefined?
null is assigned, where as undefined is when javascript tell you something is empty
Why is it a good habit to include “labels” when you log values to the browser console?
gives an identifier for your console log
Give five examples of JavaScript primitives.
numerical value, string, boolean, null, undefined,
What data type is returned by an arithmetic operation?
number
What is string concatenation?
appending a string to the end of another string
What purpose(s) does the + plus operator serve in JavaScript?
addition in math and concatention for strings
What data type is returned by comparing two values (, ===, etc)
boolean
What does the += “plus-equals” operator do?
it is the addition assignment plus whatever string or data type is being added from the original variable
What are objects used for?
group together data, create subdivisions of data
What are object properties?
they are sub divisions of objects that store similar data
Describe object literal notation.
curly braces
How do you remove a property from an object?
delete (name of propert)
What are arrays used for?
to store items with similar data with an order.
Describe array literal notation.
square bracket with data values inside
How are arrays different from “plain” objects?
data is indexed, with a set order
What number represents the first index of an array?
0
What is the length property of an array
number of values within the array
How do you calculate the last index of an array?
.length-1
what is a function in Javascript?
function does code repeatable without typing out the code over and over
Describe the parts of a function definition
function keyword, name(optional), parameters, curly brace, followed by code and return statement(optional). then closing curly brace
Describe the parts of a function call.
the function name followed by parenthesis
When comparing them side-by-side, what are the differences between a function call and a function definition?
no function keyword on a function call, no curly braces, and parameters in the function definition versus arguments in function calls
What is the difference between a parameter and an argument?
parameter is a placeholder, arguments fills the parameters of the data
Why are function parameters useful?
individual data for multiple uses
What two effects does a return statement have on the behavior of a function?
spit a value, and stop the the code after it to execute
Why do we log things to the console?
verify output and track progress for (debugging)
What is a method?
function stored in a object
How is a method different from any other function?
methods are attached to objects functions can be called by itself
How do you remove the last element from an array?
.pop method
How do you round a number down to the nearest integer?
math.floor
How do you generate a random number?
math.random method
How do you delete an element from an array?
.splice( where to start, how many items to remove)
How do you append an element to an array?
.push( ) method
How do you break a string up into an array?
.split( )method
Do string methods change the original string? How would you check if you weren’t sure?
no
Is the return value of a function or method useful in every situation?
not all the time
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?
booleans
What is the purpose of an if statement?
to check a condition if yes or no do it
Is else required in order to use an if statement?
no not necessary