JavaScript Promise and Async/Await

async function always returns a promise. So, I added following promise example firstly.

Promise Examples

The following three examples are doing same job. I used function statement and arrow function in Promise.

Promise with Function Declaration(Function Statement)

Promise with Arrow Function

Async Examples

Async Function Declaration(Function Statement)

Async Function Expression

Async Arrow Function

Await Examples

Node.js babel different usage transpiling to ES5 and Debugging

There are different usages of babel tool. I put a sample package.json file. Notice that there are scripts block which has different usages.

Creating Babel configuration file


  "presets": [
  "plugins": [
  "sourceMaps": true,
  "retainLines": true

Running with Babel-node

//If you have installed babel-cli package globally, run below code.
babel-node --presets=env --plugins=transform-runtime src


//If you have .babelrc config file, run below code without specifying inline arguments.
babel-node src


//If you have installed babel-cli package locally, run below code.
./node_modules/.bin/babel-node --presets=env --plugins=transform-runtime src
Continue reading