I would like to know if people could modify an HTML 5 game's code
Like all web technologies, the client has full access to the local code; they can browse the source, modify it and send unexpected data to the server, or sniff what the server is sending to the client, but not displayed.
to harm either the server
Yes. This is not specific to games, though, you could check for any web security resources and they would apply to games.
or other players whom visit the page.
Maybe. The least bad thing that could happen to them is that one malicious client is causing a DoS (denial of service) attack and prevents the other players from playing; the worst that could happen is that their private data is stolen. But again, this is not specific to games.
If the game code and content is downloaded from the server, and the player can play the game without needing to communicate with the server again, there is less worries to have. Your players will be able to cheat, but since they're in their own bubble, it's generally not a concern.
If you introduce the features that you have mentioned, then, yes, at that point, it starts to be a concern: cheating from players, players trying to hack the server to get more in-game currencies, get the other players information, etc.