Well, for me personally it depends fully on what type of javascript game that it is:
In the case of a single player game...
let them cheat! Lets say you rewrite the wheel, and put as many roadblocks in the way of a determined hacker as you want, at the end of the day, the player will only undermine the fun of the game for themselves if they cheat. If anything, the more in the way of trying to 'protect' your game, that much more of a challenge it is to hackers who will find your feeble attempts entertaining. In the end, players that don't want to cheat, wont. I personally would even add a console command or a cheat menu, to make double sure that there is no challenge here for hackers. Think of any single player game with a console (skyrim, fallout 3/4, etc...) --- at a certain point, it really doesn't matter if someone cheats or not. I personally would say the same thing for lan games as well (depending on the game).
Otherwise, when it actually matters...
In games where cheating not only ruins the fun for the player, but for potentially all players (including those that don't want to cheat), then you really have absolutely no choice but to run anything of importance on a server. You most likely will be doing this already for any game that has a great deal of players in it that must all communicate with each other. Connections to the server, and communications to and from the server can/should all be logged and reviewed to make sure no funny business is going on. It is important that you never trust any communication that is directed towards your server. For the same reason as the single player game, you can do nearly nothing in the way of 'preventing cheating' on your players computer and any local security measures are little in the way of challenge; Because of this sent messages that 'look legit' can easily be far from it --- it is your job to check everything and trust nothing. If something does not match up exactly with what you would expect, log it and toss it.
Why does javascript suck?!
Javascript is easy to screw with in a web browser. Firstly, it's all in plain text english, and most browsers these days pride themselves on showing you everything they can about what is on a web page on the nuts and bolts level. This means, with nothing more than a few mouse clicks later, boom, any javascript game can be viewed and easily changed. Whereas Javascript might be the easiest in these regards to 'figure out', there is not a programming language or environment known to man, that someone can't figure out. The problem is always the same: If a CPU is expected to know what to do with something, a human can figure it out too (even though it can be an absolute pain, to the point that most would rather give up than continue trying--- but not all do).
The same holds true for packets. Not only can the codes that run on your computer be completely broken apart and added to, but the communications coming from your computer to a server can be altered, resent, and forged altogether. For instance, if in a game, your computer sends to a game server out there 'hey, I just got 1 point', you can watch that communication and send it again and again... so instead of just having the one point that the game generated, you now have just as many as you want to request- or if you can figure out the communication and edit it yourself, you could easily send over 'hey, I just got 9999 points'.
Things not to do
If you have a multiplayer game, DON'T just obfuscate it and call it a day, that stops absolutely nobody and most likely just as easy as it was for you to obfuscate, hackers have already written a tool to reverse it (or if not already most likely momentarily)... Not only can whatever mess you made can be cleaned up, but most of the time whatever you had can be entirely recreated like nothing ever happened (MCP comes to mind). All this could ever serve to do is slow someone down, but not for long. Again, you could obfuscate your code for a single player game, but what would even be the point of that other than to give hackers reason to release all manner of trainers to try and enable cheating --- you should just beat them to the punch and be done with it, rather than invite hackers to think too much about your game in particular.
tl;dr
Because of limitations of programs and packets, for single player games there is absolutely nothing you can do to stop someone from cheating, so don't bother and rather embrace that fact. For multiplayer games, the only thing you can do is to treat all communications from a player as hostile until you can definitively prove otherwise.
setInterval(function() { $("#bigCookie").click(); }, 10);
I was the best cookie clicker of my class. \$\endgroup\$ – AmazingDreams Dec 20 '15 at 13:49Game.cookies=999999999
:-) \$\endgroup\$ – wb9688 Dec 20 '15 at 17:58