added promises
This commit is contained in:
18
promise2.js
Normal file
18
promise2.js
Normal file
@@ -0,0 +1,18 @@
|
||||
let batorzsido = false;
|
||||
|
||||
let myPromise = new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
if(batorzsido){
|
||||
resolve("Ez a zsidó templomban is fingik");
|
||||
}
|
||||
reject("Ez a zsidó nem fingik a templomban");
|
||||
}, 2000);
|
||||
})
|
||||
|
||||
//setTimeout(asd, 3000);
|
||||
|
||||
function asd(){
|
||||
myPromise.then(result => {console.log(result);}).catch(error => {console.log(error);});
|
||||
}
|
||||
|
||||
asd();
|
||||
Reference in New Issue
Block a user