When you say "looks like an error", did you try running it? I assume you have a web browser handy.
All the examples in that section both look correct to me, and run as I'd expect in the JS environment I have closest-to-hand.
If you want help on the syntax, you should pose a more-specific question. Exactly what code looks like an error, and why do you think it's an error, and so on?