Posted By

Piotrek290 on 09/18/09


Tagged

javascript object prototype extend


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

hERB
Piotrek290


Object extending


 / Published in: JavaScript
 

  1. Object.extend = function(object, extend){ for(propety in extend)object[propety]=extend[propety]; };
  2.  
  3. /* Example */
  4. Object.extend(String.prototype, {
  5. camelCase : function(){return this.replace(/-(.)/gi,function(a1,a2){return a2.toUpperCase();});},
  6. share : function(a1){var ret=[];for(var x=0;x<this.length;x+=a1){ret.push(this.slice(x,x+a1));};return ret;}
  7. });

Report this snippet  

You need to login to post a comment.