How to declare constants in JavaScript

2 Answers

0 votes
const CONSTANT_VAL = 8575;

// CONSTANT_VAL = 12; // TypeError: invalid assignment to const 'CONSTANT_VAL

console.log(CONSTANT_VAL);




    
    
/*
run:

8575
    
*/

 



answered Jan 28, 2021 by avibootz
0 votes
const CONSTANT_VAL = 8575;

//let CONSTANT_VAL =  12; // SyntaxError: redeclaration of const CONSTANT_VAL

console.log(CONSTANT_VAL);




    
    
/*
run:

8575
    
*/

 



answered Jan 28, 2021 by avibootz
...