Given the following code (taken from this answer):
function ConstructorFunction() {
this.someProp1 = "cf1";
this.someProp2 = "cf2";
}
ConstructorFunction.prototype.someMethod = function () { /* whatever */ };
function factoryFunction() {
var obj = {
someProp1: "ff1",
someProp2: "ff2",
someMethod: function () { /* whatever */ }
};
// other code to manipulate obj in some way here
return obj;
}
let objFromConstructor = new ConstructorFunction()
let objFromFactory = factoryFunction()
console.log(objFromConstructor)
console.log(objFromFactory)
I get different looking objects in the Chrome console:
There is text (ConstructorFunction) before the constructor function object - what is this called?
Why is the object from the factory function missing this text?
Does the difference in structure affect anything about how these objects will work?