delete or override const variables in javascript Harmony / ECMAScript 6 -


reading , tinkering new features offered ecmascript 6.

the new 'const' statement writing constant variables nifty feature, adds features interesting update.

the variable created read-only, , once stated can't overridden.

edit: consequent problem arise, example, when testing code on console. running script containing const definition twice, lead error, breaking execution.

what if want release keyword? there way unset or delete variable?

i've read in this post problem affects var statement well, because environments variables created different on many level of abstraction.

how ecmascript 6 intend address issue?

it not possible redefine variables declared using const.

however, const block-scoped. address issue describe, when testing code in console have wrap script in { , }:

{ const x = 1; } { const x = 2; } 

note many browsers support const keyword not yet support block-scoped constants example above fail in chrome , firefox (see kangax's compatibility table more).


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -