I was trying some basic code when I went through this on Chrome Developers Tools console:
The language specification says that you can declare a variable starting with a letter, $ or _.
So, why is this happening? Is it just a bug or does it have some other justification?
Why it doesn't work the first time but works when re-assigning?
EDIT:
I received comments about $1 to $4 been reserved identifiers, but I still don't get why it get assigned exactly the second time (instead of the first time or never being assigned)
Quoting from the devtools documentation
Dev Tools remembers the last five DOM elements (or JavaScript heap objects) that you've selected in the tab (or Profiles panel). It makes those objects available as $0, $1, $2, $3, and $4. $0 returns the most recently selected element or JavaScript object, $1 returns the second most recently selected one, and so on.
these reserved identifiers will act differently from other regular identifiers in console.
hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With