Also to avoid any doubt: if something’s called a golfing trick, you almost certainly shouldn’t use it on normal code.
I confess I use this technique on every page on my website, in my carefully-golfed light/dark mode switcher. (https://chrismorgan.info/blog/dark-theme-implementation/ has a slightly-expanded version of it, and uses a more sensible document.querySelector instead.)
Similarly - $0 gives access to currently selected element
querySelector needs the '#' in this case.
https://bugs.chromium.org/p/project-zero/issues/detail?id=12...
FormName.FieldName.value = "foo";https://portswigger.net/research/dom-clobbering-strikes-back
> window[`test${i}`]
surely you must mean `eval('test'+i)` :)
1. It doesn’t need to be a valid JavaScript identifier, though if it isn’t you’ll need to use subscripting syntax to access it:
> document.body.id = "like-this";
> window["like-this"]
<body id="like-this">
2. It’s not added to the window object; rather, property lookup on a window object falls back to looking up elements by ID if there is no such property: > typeof example
"undefined"
> document.body.id = "example";
> example
<body id="example">
> example = "no longer an element";
> example
"no longer an element"
> delete example;
true
> example
<body id="example">one of? you have tricks better than this? this is so fucking spicy holy cow. how did i not know this? excuse me while i add this to all my future code for no good reason :).