Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const x = 'const';
- const x = 'not-const';
- Will give an error: 'constant 'x' has already been defined'
- const x = 'const';
- x = 'not-const';
- // will output 'SECRET'
- const x = 'SECRET'
- if (x = 'ANOTHER_SECRET') { // Warning! assigining a value variable in an if condition
- console.log (x)
- }
- // will output 'ANOTHER_SECRET'
- var y = 'SECRET'
- if (y = 'ANOTHER_SECRET') {
- console.log (y)
- }
- // Will throw TypeError: const 'x' has already been declared
- const x = "SECRET"
- /* complex code */
- var x = 0
- // Will reassign y and cause trouble
- var y = "SECRET"
- /* complex code */
- var y = 0
- const pi = 3.1415926535
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement