Javascript/Node.js: 2 Features that you might not know.

This is a very short article where we will be discussing two Javascript features that you may not know.
Also, you may like this article about two new Node.js features.  

So let's start,

1)Exponentiation operator(**):
This operator was added in ES6 and is supported by most of the browsers but excluding internet explorer.
It is also called an Infix operator for Exponentiation.
Before for exponentiation, we have to use Math.pow(x,y).
But now you can use x**y.

For example: 2**5 //returns 32

2)Numeric Separators:
Large numeric literals are difficult for the human eye to parse quickly,
especially when there are lots of repeating digits. To improve readability, you can use
underscores as separators in numeric literals.

For example:
let value= 100_000_000_00 //Is same as 10000000000

As of May 2020, It is supported by all major browsers (Chrome[75+], Firefox[70+], Edge, Safari[13+], Opera) (source 1, source 2 for more details about different browsers and versions supporting it) 
And if you're working on the server-side, Node.js v12.5.0 is already supporting it as well. 
Interesting note: although supported by all browsers, this is not part of any ECMAScript version yet.

I hope you like this article and if any doubts please let me know in the comment section.

Subscribe this blog for more articles on Node.js and JavaScript.
You can also follow me on Twitter or Linkedin for the latest updates.

Written By:
Saurabh Joshi


Popular posts from this blog

Node JS:Understanding bin in package.json.

Node.js: create an excel file with multiple tabs.

Node.js: Downloading a xml file from given url and reading its data elements.