Академический Документы
Профессиональный Документы
Культура Документы
Generators
Generators are functions that can be exited and later re-entered. Their context (variable
bindings) will be saved across re-entrances. A function keyword followed by an asterisk
defines a generator function, which returns a Generator object.
function* generator(i) {
yield i;
yield i + 10;
}
console.log(gen.next().value);
// expected output: 10
console.log(gen.next().value);
Further reading: https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Reference/Statements/function*
"use strict"
In normal JavaScript, a developer will not receive any error feedback assigning values to non-writable
properties
2. Object Methods
3. Prototype Methods
Event delegation
Bubbling also allows us to take advantage of event delegation — this concept relies on the
fact that if you want some code to run when you click on any one of a large number of child
elements, you can set the event listener on their parent and have events that happen on them
bubble up to their parent rather than having to set the event listener on every child individually.
Remember earlier that we said bubbling involves checking the element the event is fired on for
an event handler first, then moving up to the element's parent, etc.?
A good example is a series of list items — if you want each one of them to pop up a message
when clicked, you can set the click event listener on the parent <ul>, and events will bubble
from the list items to the <ul>.
There is another great advantage using let as it creates a new lexical environment
and also binds fresh value rather than keeping an old reference.
In constants mutation is allowed but reassignment is not allowed.
We can now have spaces in our strings, and can even start strings with
numbers.Perhaps most importantly, we can now use variables to access properties in an
object. It’s important the variable you are using references a String.
Dot notation:
OK — obj.prop_1, obj.prop$
Bracket notation:
A higher-order component (HOC) is a function that takes a component and returns a new
component. Basically, it's a pattern that is derived from React's compositional nature.
We call them pure components because they can accept any dynamically provided
child component but they won't modify or copy any behavior from their input
components.