Go Back   CodingForums.com > :: Client side development > JavaScript programming > Post a JavaScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-28-2009, 07:47 PM   PM User | #1
Renato Bebić
New Coder

 
Join Date: Sep 2009
Location: Croatia
Posts: 38
Thanks: 3
Thanked 5 Times in 5 Posts
Renato Bebić is an unknown quantity at this point
Object.extend

Code:
/**
 * Extends object with another objects properties.
 * Author: John Resigs <jeresig[at]gmail.com>
 * Modified by: Renato Bebić <renato.bebic[at]gmail.com>
 * Modified to distinct prototyped properties and extend
 * them to hosts prototype.
 * Tested and works on: Firefox 3.5, Chrome 3, Safari 4 
 *
 * @param object to extend with
 */
Object.prototype.extend = function( object ) {
	var property, getter, setter, target;
	for ( property in object ) {
		getter = object.__lookupGetter__( property );
		setter = object.__lookupSetter__( property );
		target = object.hasOwnProperty( property ) ? this : this.__proto__;
		if ( getter )
			target.__defineGetter__( property, getter );
		else if ( setter )
			target.__defineSetter__( property, setter );
		else
			target[ property ] = object[ property ];
	}
};

Last edited by Renato Bebić; 09-28-2009 at 08:03 PM..
Renato Bebić is offline   Reply With Quote
Reply

Bookmarks

Tags
extend object, extends, inheritance

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:06 AM.


Advertisement
Log in to turn off these ads.