How to create object template for gaming character in Javascript?

Most javascript game developer nowadays likes to use object template to create a new object. What is an object template? Object template is just like a blueprint which we can later use to mass produce as many objects as we want from it. For example, we can create an object template of an enemy in our game.

var noobMonkey = {
	health: 100,
	shields: 50,
	strength: 100,
	strike: function() {
		// do something here

Then we can create a new object based on this template like this…

var firstNoobMonkey = Object.create(noobMonkey);

We can even assign different property value to a different object like this…

firstNoobMonkey.strength = 50;

We can also go further to create a new property for a particular enemy at the time of it’s creation…

firstNoobMonkey.x = 30;
firstNoobMonkey.y = 30;

Template is always very useful when it comes to create a game object because of it’s “Build once and use it everywhere concept”.