ecmascript 6 - How to unset a Javascript Constant in ES6? -


i read this post, using delete keyword, can delete javascript variable. when tried same operations constant returning false when try delete constant. there way delete constants memory? tried this answer not working.

you can't directly it, looking @ specs show value can set, not over-written (such standard definition of constant), there couple of hacky ways of unsetting constant values.

using scope

const scoped. defining constant in block exist block.

setting object , unsetting keys

by defining const obj = { /* keys */ } define value obj constant, can still treat keys other variable, demonstrated the examples in mdn article. 1 unset key setting null.

if it's memory management concern both these techniques help.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -