Javascript ES6 Const can be changed when it's not allowed -
i'm playing around es6 , know const values cannot changed/reasigned. in case, why allowed change?
{ const name = 'unchangable'; sayname = (name) => { console.log(name); } } sayname('changed');
it's not changing, print value pass function not const name
.
example:
{ const name = 'unchangable'; sayname = (newname) => { name = newname; // make error } } sayname('new name')
where code equal code blow
{ const name = 'unchangable'; sayname = (somename) => { // there no relationship between `somename` , const `name` console.log(somename); } } sayname('new name');
Comments
Post a Comment