Skip to content

Instantly share code, notes, and snippets.

View alibalbars's full-sized avatar

Ali Balbars alibalbars

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