In ES5, you declare variables via var. Such variables are function-scoped, their scopes are the innermost enclosing functions. Block-scoping helps with keeping the effects of code fragments more local.

10m read timeFrom vedb.hashnode.dev
Post cover image
Table of contents
var to const / letIIFEs to blocksconcatenating strings to template literalsfunction expressions to arrow functionsHandling multiple return valuesfor to forEach() to for-ofHandling parameter default valuesfunction expressions in object literals to method definitionsconstructors to classesobjects to MapsNew string methodsNew Array methodsapply() to Array.prototype.fill()CommonJS modules to ES6 modules
6 Comments

Sort: