typescript - Why changing "const" value in Angular 2 does not give error? -


the code simple:

const num = 1; num = 2; console.log('num', num); 

in jsfiddle, browser console show following error, great:

uncaught typeerror: assignment constant variable.

however, same codes in angular 2 not give error, , @ end num equals 2. see plunker.

why changing "const" value in angular 2 not give error? bug? thanks

online typescript compiler default target lower 'es6', in generated code const replaced var compatibility, if change config.js to:

  typescriptoptions: {     emitdecoratormetadata: true,     target: 'es6'   } 

compiler output const , you'll see error.


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -