1
0
Fork 0
easejs/scripts/ex/static-members.js

28 lines
492 B
JavaScript

const Cow = Class( 'Cow',
{
'const LEGS': 4,
'private static _number': 0,
constructor()
{
// __self refers to the class associated with this instance
this.__self.$( '_number' ) = this.__self.$( '_number' ) + 1;
},
'public static create'()
{
return Cow();
},
'public static getNumber'()
{
return this.__self.$( '_number' );
},
} );
Cow.$( 'LEGS' ); // 4
Cow.getNumber(); // 0
Cow.create();
Cow.getNumber(); // 1