A constructor function is a function which returns an object when we use the new keyword. The this keyword does not refer to the function, but to this new object which is returned.
const Car = function(wheels) {
this.wheels = wheels;
};
const car = new Car(4);
console.log(car); // {wheels: 4}
In ES6, we can use classes to do the same thing:
class Horse {
constructor(legs) {
this.legs = legs;
}
}
const horse = new Horse(4);
console.log(horse); // {legs: 4}
In both cases, it is standard to use Titlecase for the Constructor / Class, and lowercase for the instance.