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

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -