Let's say I have this code:

```
(function(global) {
    function Bar(foo) {
        this.foo = foo;
        return this;
    }

    Bar.prototype.getFoo = function() {
        return this.foo;
    };

    Bar.prototype.setFoo = function(val) {
        return (this.foo = val);
    };
})(this);

```

What is the difference between creating functions like `setFoo` with `prototype` and just doing it like this:

```
function Bar(foo) {
    this.getFoo = function() {
        return this.foo;
    };
}

```

I know what prototype is and what it means, I just can't figure out, why some people assign functions with prototype, because if I assign them with this, they will be available also every time I create a new instance of Bar.