• Share

Snippet – Prototype: Object extending

Free Website

Simple snippet to learn object extending in Prototype..

Object.extend = function(object, extend){ for(propety in extend)object[propety]=extend[propety]; };

/* Example */
Object.extend(String.prototype, {
  camelCase : function(){return this.replace(/-(.)/gi,function(a1,a2){return a2.toUpperCase();});},
  share : function(a1){var ret=[];for(var x=0;x<this.length;x+=a1){ret.push(this.slice(x,x+a1));};return ret;}
});

Related posts:

  1. Snippet – jQuery: Trim strings using jQuery
  2. Fabtabulous! Simple tabs using Prototype
  3. MyTableGrid: Datagrid control using Prototype
  4. Prototip Tooltip – Prototype Plugin
  5. Form Field Validation using Prototype

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>