JavaScript is kinda weird because it uses lexical scoping for most of the part, but uses dynamic scoping for 'this'.
Lexical scoping looks sane, and it's adopted by most programming languages nowadays. Because it's much easier to reason about - it just worked as how the code was written, in the same file. While dynamic scoping would leak variables everywhere - when you need it it's not there, when you don't want it, it just sneakily replace many variables that you expect to be other things.
But there are still quite some mostly dynamically scoped languages in use like Emacs Lisp, or shell languages like Bash and Powershell. Other than dynamically is debatable faster and easier to implement, it's also handy when you override the environment variables for short shell scripts. But for large codebases it's a nightmare, so traditionally Emacs Lisp scripts have super-long-variable-names-in-order-to-avoid-collisions just like writing CSS, and people had enough now so in newest version people can have a syntax that can enable lexical scoping.
https://www.ecma-international.org/ecma-262/5.1/#sec-10.2 https://www.ecma-international.org/ecma-262/5.1/#sec-13.2
https://2ality.com/2011/04/ecmascript-5-spec-lexicalenvironm...
I don't think dynamic scoping is the only reason for this. Scheme has lexical scoping yet long-identifier-names are popular with scheme as well.
Personally I prefer lexical scoping with long-identifier-names. I find it more pleasant to read. And with modern auto-completion systems, it's no longer inconvenient to write code like that.
Because in Scheme there are safe variables in closures so it can just named as <already-very-long-function-name>, while in Emacs Lisp it's literally leaking everywhere so it need to be <plugin-name>-<feature-name>-<sub-feature-name>-<repeat-the-feature-name-game-for-a-while>-<and-eventually-the-already-very-long-function-name> instead.
Under dynamic scope you have the additional problem that a global name can be be overridden by accident by local names that clash with it.
Rather than trusting mere identifier length to address that problem, there is a namespacing convention to deal with it: putting "earmuff" asterisks on the names of global variables.
For example, when there was no namespace for JavaScript, people can easily simulate modules/namespaces with lexical closures. For a lot (not all of course) of bundling systems, modules/namespaces are just syntactic sugars on top of lexical closure.