I've got a javascript object which will often need to be initialised with 5 + variables, I don't think using a bunch of setters for each variable every time a new Person
object is created would be nice. A constructor perhaps? How can I put a constructor into my module object? I've found an example of how to write constructors in javascript but I'm not sure if it fits in with how this object is designed: Constructors in JavaScript objects
I'd like to be able to initialise each Person with variables to set Person's privates:
var p = new Person(a, b, c, d, e);
My object:
var Person = (function() {
// private
var name;
var gender;
var weight;
var location;
return {
// public
myfunc: function() {
}
}
})();