Q:

What objects are present in memory in this JavaScript?

Given the following code, what user-defined objects are in memory after line 1 and after line 2?
function MyCtor() {}

//At this point a single user-defined object exists, the constructor function `MyCtor`

var v = new MyCtor();

//Here in addition to the constructor function defined above we have `v` (a `MyCtor` instance) and another instance of `MyCtor` acting as `v.__proto__`. So that is 3 objects in total.

A:

After the first line there are two objects. There is the function object, and there is the prototype object for the function.
(Well, the function is created already when the code is parsed, so the objects exist before the code even starts to execute. More correct would be to say that the first line causes two objects to exist.)
After the second line there is just one more object, the instance of the object. The __proto__ property of the object does not contain another instance of the object, it's a reference to the prototype object of the constructor function.
Example:
function MyCtor() {}

console.log(MyCtor.prototype);

var v = new MyCtor();

console.log(v.__proto__);
console.log(MyCtor.prototype === v.__proto__);

Output:
MyCtor { }
MyCtor { }
true

Demo: http://jsfiddle.net/323bg/

