Javascript Essentials Flashcards
memorize terms
Function Overloading
the ability to create multiple functions of the same name with different implementations
whitespace
invisible characters that create literal ‘space’ in your written code
Immediately Invoked Function Expressions
a JS expression that runs as soon as it’s defined
Array
a variable that holds many values insdie of it []
arguments
the parameters that you pass to a function
mutate
to change a value
immutable
cannot be changed
JSON
Javascript Object Notation
First Class Functions
everything you can do with other types you can do with functions, assign them to variables, pass them around, create them on the fly. function names can be anonymous. Functions are an object whose code happens to be the properties on that object.
First Class Functions = Functional Programming
Function expression
a unit of code that results in a value. It doesn’t have to save a variable. Usually created on the fly.
function statement
a function that just ‘does work’
Namespace
a container for variables and functions, typically to keep variables and functions with the same name seperate.
Primitive Property
number, boolean, string
Object Property
Object within Object
Function Method
a function that is connected to an object
Operator
a special function that is syntactically (written) differently.
Precedence
which operator gets called first (PEMDAS)
Associativity
what direction operator functions get called in L->R R->L
coercion
converting a value from one type to another
array.filter()
creates a new array with all elements that pass the test implemented by the provided function.
array.map()
creates a new array with the results of calling a provided function on every element in the calling array
array.reduce()
method executes a reducer function (that you provide) on each element of the array, resulting in a single output value. The reducer function takes four arguments:
Accumulator (acc) Current Value (cur) Current Index (idx) Source Array (src)
Your reducer function’s returned value is assigned to the accumulator, whose value is remembered across each iteration throughout the array and ultimately becomes the final, single resulting value.
trim
method removes whitespace (spaces, newlines, tabs, and similar) from the start and end of a string
padstart()
The padStart() method pads the current string with another string (multiple times, if needed) until the resulting string reaches the given length. The padding is applied from the start (left) of the current string.
string.length()
accessing individual characters in a string looks like accessing array elements. It returns count of total number of characters. The length of java string is same as the unicode code units of the string.
rest parameters (…Args)
it can useful for a function to accept any number of arguments. The rest parameter syntax allows us to represent an indefinite number of arguments as an array.
array.indexOf()
method searches through the array from the start to the end and returns the index at which the value was found, or -1 if not found.
array.slice()
takes the start and ending indexes and returns an array that has only the elements between them. The slice() method returns a shallow copy of a portion of an array into a new array object selected from begin to end (end not included). The original array will not be modified.