Return to Snippet

Revision: 8031
at August 27, 2008 15:45 by dbug13


Updated Code
function BaseClass(extended_props){
	this.extend = function(props){
		for(var i in props){
			this[i] = props[i]
		}
	}
	
	if(extended_props){
		this.extend(extended_props);
	}
	
	if(this.init){
		this.init();
	}
}

var Foo = new BaseClass({
	name: "Jamie Allison",
	init: function(){
		alert("Called from Foo.init()");
	}
});

Foo.extend({
	age: 32
});

alert("Age is: " + Foo.age);

Revision: 8030
at August 27, 2008 15:43 by dbug13


Initial Code

                                

Initial URL

                                

Initial Description

                                

Initial Title
Basic Object extending

Initial Tags
javascript, textmate

Initial Language
JavaScript