DEV Community

Nill Webdev
Nill Webdev

Posted on

3 New JavaScript Features in ES2020 That You Should Know

So here are some cool features to try out!
It would be really helpful if you like, share and comment.

1. BigInt
BigInt, one of the most anticipated features in JavaScript, is finally here. It actually allows developers to have a much greater integer representation in their JS code for data processing for data handling.

At the moment the maximum number you can store as an integer in JavaScript is [pow(2, 53) - 1]. But BigInt actually allows you to go even beyond that.

BigInt

However, you need to have an [n] appended at the very end of the number, as you can see above. This [n] denotes that this is a BigInt and should be treated differently by the JavaScript engine (by the v8 engine).

This improvement is not backward compatible because the traditional number system is IEEE754 (which cannot support numbers of this size).

2. Dynamic import
Dynamic imports in JavaScript give you the option to import JS files dynamically as modules in your application natively. This is just like how you do it with Webpack and Babel at the moment.

This feature will help you ship on-demand-request code, better known as code splitting, without the overhead of webpack or other module bundlers. You can also conditionally load code in an if-else block if you like. The good thing is that you actually import a module, and so it never pollutes the global namespace.

Dynamic import

3. Optional Chaining
Optional chaining syntax allows you to access deeply nested object properties without worrying if the property exists or not. If it exists, great! If not, [undefined] will be returned. This works on object properties but also on function calls and arrays. Super convenient! Like this example:
Optional Chaining

Thank you very much for reading this article.

Comment any features that you like of javascript and a feature that you think should be improved in the next ES

Top comments (0)