I am trying to write a method for one object that can create a new instance of a separate object. Is this possible with javascipt?
function Library () {
this.name = "My Library";
this.createShelf = function () {
<some code>
};
}
function Shelf (shelfNumber) {
this.shelfNumber = shelfNumber;
}
var myLib = new Library();
myLib.createShelf();
Is is possible to create a new instance of Shelf by using a method in Library?