-
Take a look at these examples and try to guess what will be the execution order https://jsbin.com/kaloxoniwe/edit?js,console
-
Write examples with different promise methods and check the console to see the difference https://jsbin.com/wejadutuve/edit?js,console
-
Here we have few methods that need to run one after another. Try to call them using promise and using callback. https://jsbin.com/qukehubamo/edit?js,console
Доволі часто буває що нам потрібно кілька разів виконувати одну і ту ж дію. Для цього використовують функції (reusable block of code). По факту, це спрощує твій код, бо тобі не потрібно кілька разів писати одне і теж, ти можеш створити одну функцію і виконати її кілька разів.
Приклад звичайної функції
function sayHello() {
alert('Hello !');
}