Javascript Flashcards
What is the purpose of variables
variables hold a value of something
How do you declare a variable?
use the operator to declare a variable
How do you initialize ( assign a value to) a variable
you’d use the assignment operator
What characters are allowed in variable names?
letters dollar signs and underscore and numbers as long as it doesnt start with a number
What does it mean to say that variable names are “case sensitive”?
If its not case sensitive then two of the same words are different values
what is the purpose of a string?
Its a series of characters in a row. Data that is not code.
what is the purpose of a number?
calculations
What is the purpose of a boolean
to represent logic values and see whether its true or false
What does the = operator mean in JavaScript?
Its the assignment operator
How do you update the value of a variable?
set the old value on the left of the assignment operator and the new value on the right
What is the difference between null and undefined?
Null is a placeholder and undefined is javaScripts way of saying empty
Why is it good habit to include “labels” when you log values to the browser console?
It’ll give us a point of reference
Give five examples of JavaScript primitives
Strings, booleans, undefined, numbers, and null.
What data type is returned by an arithmetic operation?
A number.
What is string concatenation?
Joining two or more values together to form a new string.
What purpose(s) does the + operator serve in JavaScript?
To add numbers and to concatenate strings
What data type is returned by comparing two values
booleans
What does the += “plus-equals” operator do?
adds the value of the right operand to a variable and assigns the result to the variable
What are objects used for?
To create a model of something you would recognize in the real world. All stored together in one area
What are object properties?
They tell us about the object. Variables that live inside an object.
Describe object literal notation
The object the key value pairs inside curly braces
How do you remove a property from an object.
The delete operator
What are the two ways to get or update the value of a property?
Dot notation and bracket notation
What are arrays used for
it stores a list of values/groups of similar data
Describe array literal notation
variable then bracket index values end with commas brackets
how are arrays different from “plain” objects?
Arrays are listed in an order
what number represents the first index of an array
0
what is the length property of an array?
arr.length and gives the total amount of index in an array
how do you calculate the last index of an array?
Array.length - 1
What is a function in JavaScript?
A repeatable chunk of code with a specific purpose.
Describe the parts of a function definition
Function name parameter code block and function
Describe the parts of a function call.
The function name and the parentheses which is where arguments are passed through
When comparing them side-by side, what are the differences between a function call and a function definition?
definition has a code block.
What is the difference between a parameter and an argument?
parameters are placeholders for arguments that don’t ahve a known value.
Why are function parameters useful?
They are placeholder for arguments. If there were not parameters the behavior would always be the same. It gives us the ability to allow our behavior to act based on a certain set of values.
What two effects does a return statement have on the behavior of a function?
It causes the function to produce a value we can use in our program and prevents anymore code from running
why do we log things to the console.
To test debugging and inspect if our code works
what is a method?
A function which is a property of an object.
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 delete an element from an array?
splice();
How do you append an element to an array?
push();
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?
They do not, and console.log the original string and go to the MDN and look at the documentation of the return value.
Roughly how many string methods are there according to the MDN web docs?
A lot
Is the return value of a function or method useful in every situation?
Sometimes but not all the time
Roughly how many array methods are there according to the MDN web docs? a
A lot
What three-letter acronym should u always include in your Google search about a javascript method or CSS property?
MDN
give 6 examples of comparison operator
< > <= >= !=== ===
What data type do comparison expressions evaluate to?
booleans
what is the purpose of an if statement?
It evaluates if a condition is true then runs the code block