首页 > 其他分享 >Chrome DevTools declare const variable twice not working All In One

Chrome DevTools declare const variable twice not working All In One

时间:2022-09-28 11:46:31浏览次数:86  
标签:const name working Chrome re let variable declare

Chrome DevTools declare const variable twice not working All In One

Uncaught TypeError: Assignment to constant variable.

const arr = ['9', '1', '3', '7', '12', '37', '23'];

// re-assignment ❌
arr =  [9, 1, 3, 7, 12, 37, 23];

// Uncaught TypeError: Assignment to constant variable.

solution ✅

re-declare const is OK ✅, but re-assignment const is totally Wrong ❌.

const arr = ['9', '1', '3', '7', '12', '37', '23'];

// re-declare ✅
const arr =  [9, 1, 3, 7, 12, 37, 23];

wrong double re-declare way, no meanings at all!

You can’t redeclare let variables in the same scope in a JavaScript program, this is the designed behavior, it won’t work anywhere.

let name = 'Jack';`
let name = 'John';
// Uncaught SyntaxError: Identifier 'name' has already been declared

let name = 'Jack';

let name = 'John'

https://forum.freecodecamp.org/t/declare-with-let-in-chrome-bug/354865

refs

https://stackoverflow.com/questions/68355442/javascript-let-double-declaration



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载

标签:const,name,working,Chrome,re,let,variable,declare
From: https://www.cnblogs.com/xgqfrms/p/16737425.html

相关文章