========================================================
function startAnimation() {
......
}
function stopAnimation() {
........
}
========================================================
var Anim = function() {
......
};
Anim.prototype.start = function() {
......
};
Anim.prototype.stop = function() {
......
};
/* usage. */
var myAnim = Anim();
myAnim.start();
...
myAnim.stop();
========================================================
var Anim = function() {
......
};
Anim.prototype = {
start: function() {},
stop: function() {};
}
========================================================
Function.prototype.method = function(name, fn) {
this.prototype[name] = fn;
};
var Anim = function() {};
Anim.method('start', function() {});
Anim.method('stop', function() {});
========================================================