Sign Up Now!

Sign up and get personalized intelligence briefing delivered daily.


Sign Up

Articles related to "es6"


You Should be Using esm

  • Front-end developers could bundle cjs-based apps with tools like webpack into single-file scripts that browsers could load and run.
  • On the other hand, js modules were statically analyzable, meaning that a new breed of tools like Rollup could analyze the js files to do useful things like tree-shaking, which is a process that removes unused code from bundles.
  • When the ES2015 spec (then called ES6 or "harmony") was published, a project called 5-to-6, later renamed Babel, came along as a way to let JS programmers write their apps using the awesome new ES6 features, while shipping code that older browsers and Internet Explorer could support.
  • More than that, though, transpiling subtly communicates that "this code isn't ok by itself, it needs extra processing to be OK", and we shouldn't want to say that about native modules, even if CJS had a head start.

save | comments | report | share on


You Should be Using esm

  • Front-end developers could bundle cjs-based apps with tools like webpack into single-file scripts that browsers could load and run.
  • On the other hand, js modules were statically analyzable, meaning that a new breed of tools like Rollup could analyze the js files to do useful things like tree-shaking, which is a process that removes unused code from bundles.
  • When the ES2015 spec (then called ES6 or "harmony") was published, a project called 5-to-6, later renamed Babel, came along as a way to let JS programmers write their apps using the awesome new ES6 features, while shipping code that older browsers and Internet Explorer could support.
  • More than that, though, transpiling subtly communicates that "this code isn't ok by itself, it needs extra processing to be OK", and we shouldn't want to say that about native modules, even if CJS had a head start.

save | comments | report | share on


Three dots ( … ) in JavaScript

  • We can use three dots … in two different ways as spread operator and rest operator.
  • In myFunc's last parameter prefixed with … which will cause to all remaining arguments placed within the javascript array.
  • Rest parameters can be destructured (arrays only), that means that their data can be unpacked into distinct variables.
  • The spread operator is used to expand elements of an iterable (like an array) into places where multiple elements can fit.
  • When we see three dots (…) in the code, it's either rest parameters or the spread operator.
  • When three dots (…) is at the end of function parameters, it's "rest parameters" and gathers the rest of the list of arguments into an array.
  • When three dots (…) occurs in a function call or alike, it's called a "spread operator" and expands an array into a list.

save | comments | report | share on