I played a little with class / function / prototype inheritance and worked on a decent setup. Something simple that I understand.
http://jsfiddle.net/rudiedirkx/rwPeD/6/
For debugging purposes, I wanted to print in each constructor which object this constructor called. For example, the Ronin constructor calls the Ninja constructor and calls the Person constructor. For this, I made a function get_class:
function get_class(obj) {
var C = String(obj.__proto__.constructor);
return C.match(/function (\w+)\(/, C)[1];
}
and it wonβt work. He always returns "Face." What for? Each "class" has its own constructor, right? If I do console.log(this)in every constructor, Chrome Devtools knows what type of object is. How do I get (with vanilla JS)?
PS. Full output in my Chrome:
