function Test() {
  this.log = function(val) {
    console.log('test');
  };
}
var test = new Test;
test.log();
and
function Test() {}
Test.prototype.log = function() {
  console.log('test')
};
var test = new Test;
test.log();
i.e. a method in a class is declared in the prototype or in this. The result appears as one: method, the newly created object so that it works
