Have a look on my code. I don't understand how It's working
function doSomething() {
  this.testProp = 'testProp';
}
doSomething.testProp1 = "testProp1";
var doSomeInstancing = new doSomething();
console.log("doSomething.testProp:" + doSomething.testProp);
//undefined
console.log("doSomething.testProp1:" + doSomething.testProp1);
//testProp1
console.log(doSomething.hasOwnProperty('testProp1'));
//true 
console.log("doSomeInstancing.testProp:" + doSomeInstancing.testProp);
//testProp
console.log("doSomeInstancing.testProp1:" + doSomeInstancing.testProp1);
//undefined   
console.log(doSomeInstancing.hasOwnProperty('testProp1'));
//falseThe question is why testProp is undefined in doSomething and not in doSomeInstancing and vice versa for testProp1.
 
                        
You are dealing with two distinct objects here:
the function:
doSomethingthe object:doSomeInstancingBoth are objects and both can have properties.
doSomeInstancingis the object returned from the function when you callnew doSomething()and it is whatthisrefers to in the body of the function. Adding properties to this object has no effect on the other object, thedoSomethingfunction. The opposite is also true.If you are trying to inherit a property, you are actually looking for a third object:
doSomething.prototype. This is a property of functions that points to an object that instances will be linked to.doSomeInstancingwill inherit from this object to in the prototype chain. For example: