This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Основная идея async await - избавиться от коллбеков, которые использую промисы, интуитивно понятный механизм | |
отлова ошибок через try catch ну и последовательная обработка, представляющая собой "синхронное" представление | |
*/ | |
function baz() { | |
return new Promise((res) => { | |
setTimeout(() => { | |
res('hey baz') | |
}, 500) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// в переменную "a" копируется ссылка на объект "b" | |
var a = b = { | |
value: 1, | |
}; | |
var b = { | |
value: 2, | |
}; | |
// следовательно когда изменяются какие-то поля объекта в переменной "a" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Сильные стороны | |
* 1) Композиция промисов (chaining) | |
* 2) API - методы типа all и race | |
*/ | |
// * * * * * Default composition * * * * * | |
// всегда использовать return внутри then или выдавать ошибку при помощи throw | |
function promiseAxios() { | |
axios.get("http://localhost:8080/api/user") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const _arr = [ | |
{ name: 'Mark', age: 21 }, | |
{ name: 'Dan', age: 22 }, | |
{ name: 'Zoe', age: 29 }, | |
{ name: 'Victor', age: 21 }, | |
{ name: 'Martin', age: 21 } | |
]; | |
const filtered = _arr.filter(i => i.age === 21 ); |
NewerOlder