/ Published in: JavaScript
This is just a blank skeleton to show the syntax of the preferred method of writing JavaScript in an OOP manner; a JSON look and feel.
Expand |
Embed | Plain Text
var yourObjectName = { property1: "some string", property2: 0, cities: new Array ( "miami", "atlanta" ), states: ["florida", "georgia"], numbers: { 0, 1, 2 }, method2: function(args) { return args; }, method3: function(args) { return this.method2(args); } }; alert(yourClassName.property1); alert(yourClassname.method2("send me back")); alert(yourClassname.method3("send me back"));
Comments
Subscribe to comments
You need to login to post a comment.

Actually, this is not a class but rather an object with its very own properties and methods.
If the intend is to isolate the method and property to avoid name clashes and accidental overriding, you may be interested by the "module pattern" which is more complete (see http://yuiblog.com/blog/2007/06/12/module-pattern/)
my mistake, snippet edited.