Javascript Module Pattern / Prototype Pattern : can't figure out this code

You are right but we’d have to be using Object.create instead of new and we’d have to provide a init object or a init function instead of the current constructor. Instead of building the prototype property object we would be using an object as a prototype for another.

var Mapster = {};

Mapster.zoom = function() {
  console.log(this.gMap);
};

var m = Object.create(Mapster, {gMap: {value: 'm'}});

m.zoom(); // 'm'

Mapster.zoom = 'changed';
m.zoom; // 'changed'
m.gMap; // 'm'

The big difference is that with using a constructor function, Mapster is a function the same way native Array is, m constructed with new Mapster is recognizable as a Mapster the same way ['m'] is recognizable as an Array. With using {} for Mapster and Object.create for building m, both are just Objects. Is the first one good or the second one good, that’s a either a choice or an alternative, but looking at the available JavaScript docs, they tend to list Something.prototype.SomethingElse.

We can always do this:

var Mapster = function(arg) {...};
Mapster.prototype = Object.create(Higher.prototype)

to avoid using new and get something from both worlds: constructor functions and prototype objects for the prototype property object.