Javascript Flashcards
What is purpose of variables
To assign a value to them
How do you declare a variable
var variable;
How do you initialize (assign a value to) a variable
var variable = ‘value’
What caracters are allowed in variable names?
numbers and some signs $
What does it mean to say that variable names are “case sensitive”?
variable is different from Variable they can have two different values
What is the purpose of a string?
to store and pass around a series of characters, so text
What is the purpose of a number?
Math and quantities
What is the purpose of a boolean?
True and False decision making
what does the = operator mean in JavaScript?
It gives value to a variable
How do you update the value of a variable?
Assign it a new value
What is the difference between null and undefined?
It’s intentional to put null
null always needs to be assigned a value whereas undefined wasn’t assigned anything
Why is it a good habit to include “labels” when you log values to the browser console?
Gives us a point of reference
Give five examples of JavaScript primitives
String, number, boolean, null, and undefined
What are objects used for?
Place to store multiple values
What are object properties?
pieces of data glued onto an object
Describe object litertal notation
The syntax to create an object
How do you remove a property from an object?
using the operator delete
What are the two ways to get or update the value of a property?
using dot notation or bracket notation
What are arrays used for?
To store value inside at specific indexs
Describe array literal notation
var something = []; and each value is separated by a comma
How are arrays different from “plain” objects?
0
What is the length property of an array?
Tells us how many items are in the array
How do you calculate the last index of an array?
length - 1 and you’ll be able to get the final index
What is a function in JavaScript?
A set of instructions that is repeatable
Describe the parts of a function definition.
function name(parameter){ parameter must be present; return value; }
Describe the parts of a function call
console.log(nameOfFunction(arguments));
When comparing them side-by-side, what are the differences between a function call and a function definition?
Calling is utilizing the function and the defining it is making the expression that you want it to function key word is the most notable difference between the two
What is the difference between a parameter and an argument
a parameter is a variable that is needed for the function to run, an argument is passing a value to that function to allow it to work with that value
Why are function parameters useful
allows to use different values
What two effects does a return statement have on the behavior of a function
ends the function
doesn’t allow any other value to pass
What data type is returned by an arithmetic operation
A number
What is string concatenation?
The value of two strings being added together
What purpose(s) does the + operator serve in JavaScript?
To concatenates strings and arithmetic
What data type is returned by comparing two values (, ===, etc)
boolean
What does the += operator do?
take the current value and add the value inside the operator to make a new value for that variable
Why do we log things to the console?
To debug or to check things are accurate
What is a method?
a function that does something specific of an object
How is a method different from any other function?
method needs to be called with a ‘.’ functions are free floating
How do you remove the last element from an array?
.pop removes from the end
How do you round a number down to the nearest integer?
Math.floor
How do you generate a random number?
Math.random();
starts off 0 inclusive 1 exclusive
Math.random * 50; makes it 0 - 50;
Math
How do you delete an element from an array?
.shift end .pop beginning .splice area of
How do you append an element to the array?
.push
How do you break a spring up into an array?
.split
How string methods change the original string? How would you check if. you weren’t sure?
Strings are immutable can be edited but cannot be changed. Try it, return the result of the string, or check mdn
Roughly how many string methods are there according to the MDN web docs?
A lot
Is the return value of a function method useful in every situation?
No
Roughly how many array methods are there according to the MDN Web docs?
A lot
What three letter-acronym should you always include in your Google serach 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 an if statement?
decision making
Is else required in order to use an if statement
no
Describe the syntax structure of an if state
if(condition statement) {
what happens if condition is met
}
What are the three logical operators?
&& || !
How do you compare two different expressions in the same condition?
Using the logical && or || operator
WHat is JSON?
A way to transfer fdata overa network of Javascript
stands for javascript object notation
What are serializiation and deserialization
putting data in a pointer system rather than in order
What is a code block? What are some examples of a code block?
A code block is block of code within curly braces. A code within a function is considered a function code block
code within a for loop is referred to as a loop code block
What does block scope mean?
the block is delimited by a pair of curly brackets
What is the scope of a variable declared with const or let?
a block scope
What is the difference between let and const
let can be reassigned and const is permanent and not able to be reassigned, however you can add to it. So, let’s say you have a const
array. Values can still be pushed into the array they just cannot be changed
Why is it possible to push() a new value into a const variable that points to an Array
We’re not reassigning the array, we’re mutating
How should you decide on which type of declaration to use?
If you need a value that cannot change const should be used, if you need to reassign value to a variable then you should use let.
What is the syntax for writing a template literal
something something something ${variable or function}
What is string interpolation
To substitute values from a string for the values of variables or expressions
What is the syntax for defining an arrow function?
() => a - b;
() => { return a - b}
(param1, param2) => a - b;
(param1, param2) => { return a - b }
When an arrow function’s body is left without curly braces, what changes in its functionality?
You don’t need a return statement
How is the value of this determined within an arrow function
The arrow function retains the value of the this
In normal functions this is assigned at the value of call time
In arrow function this is being assigned at the time of definition