This is how i am defining a simple class with instance variables and instance methods.
ExampleClass = SC.Object.extend({
foo:undefined,
bar: function() {
this.foo = "Hello world";
console.log( this.foo );
}
}
// test
var testInstance = ExampleClass.create();
testInstance.bar(); // outputs 'Hello world'
Could anyone help me out with a similar example of class variable (or similar behavoir), and class method?
Thanks
A class Method/Property would be done like:
Then you can access it like:
But don't forget that when accessing a property (or computed property) on an instance, that you need to use
.get()
like: