The document.addEventListener() method attaches an event handler to the document. It has two required parameters, and a single optional parameter.
Functions, Callbacks and Refactoring
Dom manipulation with event driven callbacks
CSS Gradient Generator (Simple Project)
1. Global Scope – attached to ‘window’
2. Local Scope – inside a function
Another thing to remember is ‘Children’ have access to the ‘Parent’ Scope, but ‘Parents’ dont have access to ‘Children’ scope.
…..So why is this idea important?
Well because it makes code more reusable. More extensible. Little pieces of code can be configured and reused with ease. It also helps create a higher order function, and is very helpful in event handling (as outlined in this blog post).
The act of putting two or more functions together to form a new function, where the output of one function is the input of the other. Composing functions together is like snapping a series of pipes together for data to flow through.
Simply, a composion of functions ‘f’ and ‘g’ can be defined as ‘f(g(a))’, which evaluates from the inside out, and right to left.