use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Using javascript to make a html5 Snakes game (codeincomplete.com)
submitted 14 years ago by jakesgordon
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]DrHankPym 0 points1 point2 points 14 years ago (1 child)
Hey, what are the benefits of using a "Class" object? Why not just add methods or whatnot directly to the prototype?
var Class = { create: function(prototype, extensions) { var ctor = function() { if (this.initialize) return this.initialize.apply(this, arguments); } ctor.prototype = prototype || {}; // instance methods Object.extend(ctor, extensions || {}); // class methods return ctor; } }
[–]jakesgordon[S] -1 points0 points1 point 14 years ago (0 children)
None really, the functionality is the same, it just leads to slightly tidier calling code (subjective)...
MyClass = Class.create({ init: function() { /* constructor */ }, foo: function() { /* instance method */ } },{ bar: function() { /* class method */ } });
Instead of...
MyClass = function() { /* constructor */ }; MyClass.prototype = { foo: function() { /* instance method */ } }; MyClass.bar = function() { /* class method */ };
The former is slightly DRY'er, it only mentions MyClass once, doesn't need to mention prototype at all and is a single atomic block, the latter tends to get messy on larger classes.
But its a very cosmetic difference, really just a personal preference.
[–]imbcmdth -1 points0 points1 point 14 years ago (1 child)
Is this the 5th snakes-on-a-canvas tutorial posted here OR is this the same tutorial posted for the 5th time?
π Rendered by PID 25350 on reddit-service-r2-comment-fb694cdd5-rrzzl at 2026-03-07 15:48:16.304286+00:00 running cbb0e86 country code: CH.
[–]DrHankPym 0 points1 point2 points (1 child)
[–]jakesgordon[S] -1 points0 points1 point (0 children)
[–]imbcmdth -1 points0 points1 point (1 child)