Is there an easy way in JS to change a base type into a defined subtype? And does this make any sense (does anyone have any examples of when this could be used in a reasonable and useful way).
contrived example (likely with syntax errors):
var animal = function(id){
this.init(id);
}
cat.prototype.init = function(id){this.id = id;}
cat.prototype.eat = function(){something...};
var cat = function(name, fur){
this.fur=fur;
this.init(id);
}
cat.prototype = new animal();
var myanimal = new animal(getNextId()); //maybe it's a petstore or something that needs animals in their DB.
//myanimal needs to become a cat now.