I have the following code for Ecma-Script-6 template constants.
const person = 'John Smith';
console.log(person);
person = 'Naeem Shaikh';
console.log("{{After changing the value for person.name}}");
console.log(person);
of-course it doesn't work. http://www.es6fiddle.net/i3vhumdx/ It gives following error,
person is read-only
now the same thing i do with an object.
const person = {name: 'John Smith'};
console.log(JSON.stringify(person));
person.name='Naeem Shaikh';
person.age="24";
console.log("{{After changing the value for person.name}}");
console.log(JSON.stringify(person));
http://www.es6fiddle.net/i3vhzblm/
Output is:
{"name":"John Smith"}
{{After changing the value for person.name}}
{"name":"Naeem Shaikh","age":"30"}
here I am able to write into a read-only object without any problem. Can anyone explain this behavior.