Hi,
I ran into a confusion in prototypal inheritance in javascript,

in this code

var Constructor = function(){};
Constructor.prototype.hello = "hello"
Constructor.prototype.value = 1;
Constructor.prototype.test = function() { console.log(this.hello); };

// creating object from this constructor class

var rj = new Constructor();    // create an instance of A

rj.test();

console.log(rj);
console.log(rj.prototype);

**********************************output*************************************************************
hello
{}
undefined


how object is knowing that it can use test() function as it is not its
own property and neither in its prototype

even logically the properties shouldn't be copied into the new object
as int that case it will be static, while we know any further
additions to Constructor.prototype will be reflected immediately in
the object .
Is there any hidden refrence created to the Constructor.prototype in
object . Or I'm missing some general point here?


thanks.

-- 
Rohit Jangid
Under Graduate Student,
Deptt. of Computer Engineering
NSIT, Delhi University, India
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev

Reply via email to