Runtime prototype object
by Mohan[ Edit ] 2012-09-20 23:53:49
Runtime prototype object
var proto1 = {
a:function(){ return 1 }
}
var proto2 = {
a:function(){ return 2 }
}
function createObject( proto ) {
var cl = function() {}
cl.prototype = proto;
return new cl;
}
var v1 = createObject( proto1 ).a
var v2 = createObject( proto2 ).a
Print( v1() );
Print( v2() );
Print( createObject( proto1 ).a === createObject( proto1 ).a );
prints:
1
2
true
________________________________________