Whats the difference to add a method to a constrctor function with prototype
or to have it inside a constructor functions like the code below? Are both considered to be OOP?
//Constructor function
function Box(in) {
this.name = in;
}
// Method for constructor function Box
Box.prototype.showName = function() {
return this.name;
}
or
// Constructor function with method inside
function Circle(in) {
this.something = in;
{
// Method
this.showName = function();
return this.something;
}
}