I am learning how to create and write Javascript objects.
var game = { primaryStats: function (level, hp, hpcap, balance, balancecap, exp){
this.level = level;
this.hp = hp;
this.hpcap = hpcap;
this.balance = balance;
this.balancecap = balancecap;
this.exp = exp;}
However, I am also learning that Javascript employs a 'prototype' to every created object. So game
is not just a single object instance, it can also have game.prototype which is another object, but empty.
As far as I see it, both objects start off empty until you start filling it in with code. But my question is, why have prototype at all? Why not just write down code inside your object itself like above? What advantages does one get for using prototype over not using it?