I'm studying javascript prototype.
CASE 01 - works!
var A = function() {}
A.prototype.hello = function() {
console.log('hello');
}
var B = function() {}
B.prototype = new A();
var C = function (){}
C.prototype = new B();
var c = new C();
c.hello();
CASE 02 - doesn't work!
var A = {
hello : function() {
console.log('hello');
}
}
var B = {}
B.prototype = A;
var C = {}
C.prototype = B;
C.hello();
I think I didn't understand the concept of prototype and constructor or how the objects inherit each other. Can anybody explain why CASE 02 doesn't work?