Yes, I was just adding to your comment.
Just pointing out that there is a pattern of people blaming JS even though it's not related at all to the problem.
The same vulnerability would have existed regardless of whether the code was written in Python, Go, C, Erlang, Haskell, PHP or Scala...
This is a logic error - Not something that a compiler would pick up.