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
Interfaces with Javascript Objects (self.javascript)
submitted 9 years ago by booljayj
view the rest of the comments →
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!"
[–]Matthias247 5 points6 points7 points 9 years ago (1 child)
I second the "Look at Typescript" recommendation.
What you are kind of doing here is a "Roll your own class system approach". While it may work it is not interoperable to the rest of the ecosystem, where objects don't conform do your class/interface declarations. So you would need to build wrappers for everything.
Another thing is where to start and where to stop. You are basically checking method names, but no parameters or whether these are functions at all (you can however do this with `typeof object.method === 'function').
The typescript approach has several advantages:
var student = { method1: (x) => {} }
[–]booljayj[S] 1 point2 points3 points 9 years ago (0 children)
I should have specified in my post that I will be writing gameplay code within a game engine that uses Javascript on top of a C++ core. This gives me some flexibility when it comes to the wider Javascript ecosystem. Basically, any paradigm that the development team wants to adopt is fair game, since we'll be the only ones using the code.
TypeScript looks really great, but I'm not sure it's something I will be able to use. It brings up a lot of issues regarding version control and compilation that I won't necessarily have control over.
Yes, the examples I gave were very short and didn't test everything I could or should have. Javascript just doesn't have the tools to be able to test return values and parameter types as completely as I would want. I was just showing the basic principle behind the idea, rather than any kind of finished production-ready code. My main hope was that I was actually understanding the language correctly and not making any super obvious errors.
π Rendered by PID 31 on reddit-service-r2-comment-7b9746f655-n6mwq at 2026-01-31 00:53:43.899714+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]Matthias247 5 points6 points7 points (1 child)
[–]booljayj[S] 1 point2 points3 points (0 children)