This file contains hidden or 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
| promise.then(f, f) // 1.Yöntem | |
| promise.finally(f) // 2.Yöntem |
This file contains hidden or 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
| promise.then(null, errorHandlingFunction) // 1. Yöntem | |
| promise.catch(errorHandlingFunction) // 2. Yöntem |
This file contains hidden or 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
| let promise = new Promise(resolve => { | |
| setTimeout(() => resolve("done!"), 1000); | |
| }); | |
| promise.then(consolo.log); // (1) | |
| promise.then(consolo.log()); // (2) | |
| promise.then((data) => consolo.log(data)); // (3) |
This file contains hidden or 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
| promise.then( | |
| result => alert(result), | |
| error => alert(error) | |
| ); |
This file contains hidden or 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
| let promise = new Promise(function (resolve, reject) { | |
| resolve('basarili!'); | |
| reject(new Error('hata alindi!')) | |
| }) | |
| promise.then( | |
| function (result) { | |
| console.log(result); | |
| }, | |
| function (error) { | |
| console.log(error); |
This file contains hidden or 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
| let promise = new Promise(function(resolve, reject){ | |
| resolve("done"); | |
| reject(new Error("…")); // ignored | |
| setTimeout(() => resolve("…")); // ignored | |
| }); |
This file contains hidden or 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
| let promise = new Promise(function(resolve, reject) { | |
| setTimeout(() => reject(new Error("Whoops!")), 1000); | |
| }); |
This file contains hidden or 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
| let promise = new Promise(function(resolve, reject) { | |
| setTimeout(() => resolve("done"), 1000); | |
| }); |
This file contains hidden or 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
| let promise = new Promise(function(resolve, reject) { | |
| // Executor function | |
| }); |
This file contains hidden or 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
| var x = 10; console.log(x); |