2

I've always noticed that Chrome assumes variables based upon elements within an HTML document that have an ID.

For example, if I had <video id="video" src="foo.webm"></video> on my page, the variable "video" would be created automatically by the browser. No need to type out var video = document.getElementById("video");

Is this a standard browser feature? Is it something that is here with us to stay? Should I take advantage of this or be wary of it? I like it because it saves precious bytes, especially when you have a ton of element objects to define.

RickyAYoder
  • 963
  • 1
  • 13
  • 29

1 Answers1

-1

Variables are not created that way.

document.getElementById("video") means you are selecting the "video" element, not variable. Checkout CSS Selectors

fos.alex
  • 5,317
  • 4
  • 16
  • 18