Posts in Category: vanilla js

import vs require – ESM & commonJs module differences

ECMAScript Modules (ESM) are still in stage 3 (not finalized). require import Dynamic evaluation Static evaluation Throws error at runtime Throws error while parsing Non lexical Lexical As Node.js uses commonJS moduling, I will refer to the workflow of node to address the commonJS modules. And will refer the ECMAScript modules as ESM. Syntax difference CommonJS dep.js app.js ESM dep.js app.js Loading technique difference What Node.js does with

Read More




Explaining padStart & padEnd – two ES8 string methods

EcmaScript 2017 or ES8 has introduced two new String prototype methods. padStart and padEnd. Both of them will be used in display related purpose. Even the name says it’s all about “padding”. You can add some extra spaces or dashes (or any other character), before of after a string.

Read More



Explaining async await of ES8 with examples

A much awaited feature async await is available on your browser now (if you’re using chrome 55 or greater). Firefox will start supporting from version 52 an Safari from 10.1. Others will also follow the path. So, we can say we have entered the era of async await and now can

Read More