I would like to ask the following new implementation process of the two code order has an impact?

function FakeClass(){var s;this.a=1;};
var obj = new FakeClass();

// 
// obj  FakeClass  this 
function FakeClass(){var s;this.a=1;};
var obj = {};
FakeClass.apply(obj);
obj.__proto__ = FakeClass.prototype;

FakeClass.apply (obj);
obj.__proto__ = FakeClass.prototype;
does the code order of these two sentences not affect?
the interviewer said there would be an endless cycle if I wrote this.

May.14,2021

function FakeClass(){
  this.init();
};
FakeClass.prototype.init = function(){
  this.a=1;
}

in the case of the above, the order of these two sentences should be reversed. You must inherit the prototype before you can
. As for the endless loop, it should not be

.
Menu