_hyperscript icon indicating copy to clipboard operation
_hyperscript copied to clipboard

[Bug] $x and global x produce different global variables

Open rozek opened this issue 3 years ago • 0 comments

It would surprise me if the following behaviour would have been intended:

  • set $x to ...
    creates a global JavaScript variable called $x (which is a good idea as this reduces the probability of name collisions)
  • set global x to ...
    creates a global JavaScript variable called x (which is really dangerous as it could collide with already existing global names)

As there are two different global variables it becomes important to know how a global variable has been created, i.e., $x and global x can not be mixed - you cannot choose the variant which "reads better" in your current situation (which is emphasized so often within the docs)

Additionally, these side-effects in the global JavaScript namespace should definitely be mentioned in the docs!

rozek avatar Jul 26 '22 11:07 rozek