New issue
Advanced search Search tips

Issue 910992 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Dec 3
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

window[0] get undefined

Reported by zhangenm...@gmail.com, Dec 3

Issue description

UserAgent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36

Steps to reproduce the problem:
var x = 0
window[x] = 1
console.log(window[x])

can you give some explain?thanks

What is the expected behavior?
1

What went wrong?
result was undefined

Did this work before? N/A 

Chrome version: 70.0.3538.77  Channel: n/a
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version:
 
AFAICT this is working correctly as per the specification:
https://html.spec.whatwg.org/multipage/window-object.html#named-access-on-the-window-object

Since there can't be a variable that has a name beginning with a number, '0' is treated as a reference to a DOM element, hence 'undefined' is returned as there is no such element in the document.
Labels: Needs-Triage-M70
Status: WontFix (was: Unconfirmed)
Behaves the same in firefox as well

Sign in to add a comment