An iterator-object knows how to access items from a collection one at a time. It provides a next() method which returns the next item in the sequence. This method returns an object with two properties: done and value.
Iterable
An iterable-object must have a property with a Symbol.iterator key. Some built-in types i.e. Array or Map have a default iteration behavior.
for…in statement
Iterates over all the enumerable properties of an object.
for…of statement
Iterates over iterable objects i.e. Array, Map, Set, arguments, NodeList etc.
Object.create
Closure
Normally, the local variables within a function only exist for the duration of that function’s execution. A closure is a special kind of object that combines two things: a function, and the environment in which that function was created.
Below, add5 and add10 are both closures. They share the same function body definition, but store different environments.
Object.defineProperty`
Extend
Event order
Any event taking place (in W3C event model) is first captured until it reaches the target element and then bubbles up again. So we can opt to register an event handler in the capturing or in the bubbling phase by passing true or false in the last argument of addEventListener() method respectively.
Event capturing
When we use event capturing, the event handler of parent fires first and then the event handler of child.
Event bubbling
When we use event capturing, the event handler of child fires first and then the event handler of parent.
target/srcElement
An event has a target or srcElement property that contains a reference to the element the event happened on.
currentTarget
It contains a reference to the element the event is currently being handled by.
Event.preventDefault
Prevents the default action of an event without stopping further propagation of it.
Event.stopPropagation
Prevents further propagation of the current event in the capturing and bubbling phases.
Event.stopImmediatePropagation
If several listeners are attached to the same element for the same event type, they are called in order in which they have been added. If during one such call, event.stopImmediatePropagation() is called, no remaining listeners will be called.