it is because the order of your script
function testObj() {
console.log(this)
this.init();
}
testObj.prototype.init = function () {
//do something
}
var test = new testObj();
The function declaration will get hoisted to the top of the declaring scope, so you are able to create a new testObj instance but the enhancement of the prototype has not happened when the constructor is called so you won't get init method.
After hoisting the code could look like below, when new testObj() is executed, it calls the constructor function but the init method is not yet added to the prototype of testObj
function testObj() {
console.log(this)
this.init();
}
var test = new testObj();
testObj.prototype.init = function () {
//do something
}