JavaScript has its bad parts, but it's nowhere near as bad as PHP in its bad parts. JavaScript has some really good ideas in it as well. Plus, it's actually quite easy to code in JavaScript avoiding the bad parts.
I am not familiar with any precise quantification of the bad parts of JavaScript and PHP which could serve as a basis of that conclusion. That said, both PHP and JavaScript are web scripting languages that are full of bad parts. Extrapolating outwards, the entirety of modern web development is flawed.
> Plus, it's actually quite easy to code in JavaScript avoiding the bad parts.
In a sense it is harder to avoid the bad parts of JavaScript because it is tied to the browser platform, with PHP you can avoid basically all of its bad parts by simply using a different language like Clojure or Scheme.