Skip to content

Latest commit

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

mdmunir.github.io

Contoh Kode javascript

/** * Function Kelas, use to inheritance emulation * Inspiration https://code.google.com/p/cakejs/ *  * Rectangle = Kelas({ * initialize: function(x,y){ * this.x = x; * this.y = y; * }, * getArea: function(){ * return this.x * this.y; * } * }); *  * Square = Klass(Rectangle, { * initialize : function(s) { * Rectangle.initialize.call(this, s, s); * } * }); *  * var sq = new Square(5); *  * console.log(sq instanceof Square); * console.log(sq instanceof Rectangle); * console.log(sq.getArea()); *  *  *  * @author Misbahul D Munir <misbahuldmunir@gmail.com> */Kelas=function(){varc=function(){if(this.initialize){this.initialize.apply(this,arguments);}}functionExtend(dst,src){for(variinsrc){try{dst[i]=src[i];}catch(e){}}returndst;}c.prototype=Object.create(Kelas.prototype);for(vari=0;i<arguments.length;i++){vara=arguments[i];if(a.prototype){c.prototype=newa();}else{Extend(c.prototype,a);}}c.prototype.constructor=c;Extend(c,c.prototype);returnc;}

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages