Javascript doesn’t “just work”. It’s a language originally designed to glue actions to html elements and it is fundamentally broken in ways that will be never be fixed. Weird syntax, weird type coercion, horrible base types & functions, surprises galore. Even Typescript, which is basically a precompiler, is just JS with some type checking. The only reason anyone uses either is because it is ubiquitous - people have to use it.
By that logic we should all program with .bat files