Skip to content

Instantly share code, notes, and snippets.

@gossi
Created April 2, 2011 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gossi/899912 to your computer and use it in GitHub Desktop.
Save gossi/899912 to your computer and use it in GitHub Desktop.
Ideas for defining properties on Javascript "classes"
// Method 1:
MyClass = Class({
extends : "AnotherClass",
mixins : ["Event"],
construct : function () {
console.log("constructor message");
},
static : {
prop : 5
},
private : {
},
protected : {
},
public : {
testFunc : function () {
// do something ...
}
}
});
//Method 2:
MyClass = Class({
extends : "AnotherClass",
mixins : ["Event"],
construct : function () {
console.log("constructor message");
},
contents : {
"prop" : {
value : 5,
final : "true|false",
visibility : "public|protected|private",
static : "true|false"
},
"testFunc" : {
value : function () {
// do something...
},
final : "true|false",
visibility : "public|protected|private",
static : "true|false"
}
}
});
//Method 3:
MyClass = Class({
extends : "AnotherClass",
mixins : ["Event"],
construct : function () {
console.log("constructor message");
},
static : {
prop : 5
},
private : {
},
protected : {
},
public : {
testFunc : function () {
// do something ...
}
},
extended : {
"prop" : {
value : 5,
final : "true|false",
visibility : "public|protected|private",
static : "true|false"
},
"anotherFunc" : {
value : function () {
// do something...
},
final : "true|false",
visibility : "public|protected|private",
static : "true|false"
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment