One Pager Cheat Sheet
- Making JavaScript your friend is essential for any aspiring web developers, and the guide provided will help you assess your advanced knowledge in order to land the senior developer position.
- The output of this code will be Undefined Undefined Susan because of variable hoisting which causes
function declarationsandvariable declarationsto be moved to the top of the current scope, sonameis declared but not initialized when the code first executes. - Javascript
hoistingcan make variables and functions appeardeclaredbefore they are actually initialized, leading to confusion for beginners. - A
closureis a function that has access to the variables in its parent's scope, even after the parent has returned. - A
closureis used to keep a reference to the outer scope ofouterFunc(), preserving the value ofa(10) and allowingfunc()to log the result ofa+b(30). - A
closureallows an inner function to access variables in its outer function, even after the outer function has returned and its local variable have gone out of scope. - A Javascript Promise is an object serving as a
proxythat allows asynchronous operations to be handled in a synchronous manner, while representing the eventual result of the operation. Javascript promiseis an object that acts as a proxy for asynchronous functions and can exist in Pending, Fulfilled, or Rejected states.- Destructuring in JavaScript allows for easy extraction of values from an
objector anarrayand assignment of those values tovariables. - Using destructuring syntax with the
restkeyword allows you toextractan array's elements or object's properties into distinct variables in a real-world application. Themap,filter, andreducefunctions` enable developers to conveniently and quickly transform an array in a compact manner, without requiring explicit loops.- The
map()method calls a callback function to add 10 to each element of the arrayarr, resulting in a new array,mapped_arr, with values of [11 12 13 14 15 16 17 18 19 20]. - The
map()function in Javascriptloopsover an array and calls a callback on each element, returning a new array. - The
filter()method of the Array object returns a new array containing the elements for which the providedcallbackexpression returns atruthyresult. - Updated array is created with elements which satisfy the condition provided by
callbackfunction. - The
reducefunction applies a callback function (in this case,prev+next) to each item in the array, starting from an initial value (1), and returns a single value (55) which is the sum of every item in the array. - The
reducerfunction uses a user-definedcallbackorreducerfunction to apply areturn valuefrom a previous operation to thecurrent valueof anarray. - An Immediately Invoked Function Expression (IIFE) is a
self-executinganonymous function wrapped in parentheses(). - An IIFE is used to
executean anonymous function immediately in order to keep variables and function declarations out of the global scope and avoid accidental interactions with other functions and variables. - A Immediately Invoked Function Expression (IIFE) is a self-executing anonymous function that is declared and called
instantlywith a grouping operator and()to indicate its invocation.


