Don't piss on Javascript.
There's nothing wrong with pissing on Javascript, but it's unfair to mention it in the same breath as PHP. PHP sucks across the board, but Javascript has very specific and identifiable flaws. You can think of Javascript as the living embodiment of Sturgeon's Revelation.
So, for example, Javascript has quite clean variable semantics (borrowed from Scheme, no less!), making it almost a functional language, but then drapes it in an unwieldy function syntax which discourages you from using it as such. Somewhere inside Javascript you can tell that there's a pretty nice scripting language trying desperately to get out. (Hell, membranes are almost elegant.)
I wish that PHP had redeeming features like that. The only thing it ever had going for it was that 15 years ago it had a better Apache binding than any other language, making it the superior choice to CGI.