tc39 / ecma262

Status, process, and documents for ECMA-262
https://tc39.es/ecma262/
Other
14.85k stars 1.27k forks source link

Array and Object naming #3329

Closed msselwyn closed 1 month ago

msselwyn commented 1 month ago

I found this bug in javascript..

while declaring array or object using 'name' as array name or object name with keyword 'var', that array and object converted into string, other keywords like 'let' and 'const' working normally

Screenshot 2024-04-28 210157 Screenshot 2024-04-28 205455 Screenshot 2024-04-28 205343

find the attachment for your reference

ljharb commented 1 month ago

This isn't a bug; it's because in a browser, assigning to name while in the global scope sets the window.name property, and the HTML spec coerces your array into a string when doing so.