Before Node version 13, we were using the esm npm package and run our app.js using the commandnode -r esm app.js

With recent updates of Node, this is natively supported now. There are two ways we can achieve it

  • Save the file with .mjs extension.
  • Add { "type": "module" } in the nearest package.json.

Note that we only have to do one thing from the above mentioned.

If we are using Node.js version 8–12, save the file with ES6 modules with .mjs extension and run it like:

node --experimental-modules app.mjs

Leaving a clap will motivate me to write more useful tips related to JS.

ES10 is not as significant as ES6 in terms of new language features but it does add several interesting ones.

1. String.matchAll()

const matchIterator = str.matchAll(regExp);

Given a string and a regular expression, matchAll() returns an iterator for the match objects of all matches.

2. Array.flat() & Array.flatMap()

The flat() method creates a new array with all sub-array elements concatenated…

Amandeep Kochhar

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store