Firstly, JavaScript was specifically created (tailored) for browsers.
Secondly, despite all the negative rants and how awful it is, JavaScript is very flexible and forgiving which is a good thing for web pages. Imagine if you get a parser error message preventing you from viewing every page that has a little error/bug/incompatible code with your JS version, etc.