// World.js var World = { animals: {} }; // Animal.js World.Animal = function ( name, legNum ) { this.name = name; this.legNum = legNum; }; // Dog.js World.animals.Dog = function () { this.barking = false; }; World.animals.Dog.prototype = Object.create( World.Animal ); World.animals.Dog.prototype.bark = function () { this.barking = true; }; World.animals.Dog.prototype.stopBark = function () { this.barking = false; }; // World.js namespace Global; export World = { animals: {} }; // Animal.js namespace World; export Animal = function ( name, legNum ) { this.name = name; this.legNum = legNum; }; // Dog.js namespace World.animals; import World.Animal; export Dog = function () { this.barking = false; }; Dog.prototype = Object.create( Animal ); Dog.prototype.bark = function () { this.barking = true; }; Dog.prototype.stopBark = function () { this.barking = false; }; Source: https://habr.com/ru/post/225847/
All Articles