Сообщения

Сообщения за май, 2019

javascript: let const var

когда var то hoisting - это переменная объявлена в начале кода. const ссылка остается постоянной let или const - будет ли изменена ссылка в будущем. eslint - правильно ли let или const await это синхронно выполнить асинхронную функцию. в момент await выполнение текущего блока прекращается и берется следующее событие эта самая функция в await. когда await выполнился в список событий добавится что есть результат. после этого события родительский блок продолжает выполнение. serverworker - это для уведомлений - работают в фоне даже после закрытия браузера. висят в фоне, принимают сообщения. webworker - отдельный поток в браузере который общается с основным потоком.

react: super(props)

So, to conclude, If you want to use this.props inside constructor, you need to pass it in super, otherwise it’s okay to not pass props to super as we see that irrespective of passing it to super, this.props is available inside render function. src:  https://medium.com/@etherealm/super-vs-super-props-in-react-class-components-58658af6ecf2

javascript: Automatic Semicolon Insertion (ASI)

var postTypes = new Array('hello', 'there'); // <--- a="" here="" p="" place="" semicolon=""> (function() { alert('hello there') })(); src:  https://stackoverflow.com/questions/4026891/javascript-uncaught-typeerror-object-is-not-a-function-associativity-question http://inimino.org/~inimino/blog/javascript_semicolons

javascript: pretty print proxy object

        console.info(Object.assign({}, ProxyObj));

javascript: event bubbling

Click on a paragraph. An alert box will alert the element whose eventlistener triggered the event. Note: The currentTarget property does not necessarily return the element that was clicked on, but the element whose eventlistener triggered the event. Now every event goes through three phases of event propagation: 1. From window to the target element phase. 2. The event target phase and 3. From the event target back to the window phase. event.currentTarget tells us on which element the event was attached or the element whose eventListener triggered the event. event.target tells where the event started. Suppose there’s an event which shows an alert on click of the element. This event has been attached to the body. Now when the user clicks on the strong tag, currentTarget(.nodeName) will show the body whereas target will show strong as the alert output.

javascript: import v requre plus exports

module.exports = ...; is equivalent to export default ....  exports.foo = ... is equivalent to export var foo = ... Require: You can have dynamic loading where the loaded module name isn't predefined /static, or where you conditionally load a module only if it's "truly required" (depending on certain code flow). Loading is synchronous. That means if you have multiple requires, they are loaded and processed one by one. ES6 Imports: You can use named imports to selectively load only the pieces you need. That can save memory. Import can be asynchronous (and in current ES6 Module Loader, it in fact is) and can perform a little better. src:  https://stackoverflow.com/questions/31354559/using-node-js-require-vs-es6-import-export ************************************************************************ // imports // ex. importing a single named export import { MyComponent } from "./MyComponent"; // ex. importing multiple named exports import