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
npx babel src.js --out-file output.js |
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
npx babel --version | |
npm run babel --version | |
yarn babel --version | |
yarn run babel --version |
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
{ | |
"presets":["@babel/env"] | |
} |
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
{ | |
"presets": ["env"] | |
} |
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
new Promise(function (resolve, reject) { | |
setTimeout(() => { | |
try{ | |
noSuchAFunction(); // not defined | |
} catch(error) { | |
reject(error); | |
} | |
}, 1000); | |
}).catch(e => console.log('Something went wrong!')); |
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
new Promise(function(resolve, reject) { | |
setTimeout(() => { | |
reject(new Error("Whoops!")); (*) | |
}, 1000); | |
}).catch(alert); |
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
new Promise(function(resolve, reject) { | |
setTimeout(() => { | |
throw new Error("Whoops!"); | |
}, 1000); | |
}).catch(alert); |
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
promise.then(f, f) // 1.Yöntem | |
promise.finally(f) // 2.Yöntem |
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
promise.then(null, errorHandlingFunction) // 1. Yöntem | |
promise.catch(errorHandlingFunction) // 2. Yöntem |
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
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) |
NewerOlder