Created
November 3, 2014 21:57
-
-
Save ricca509/339d92d9b1d7c824077b to your computer and use it in GitHub Desktop.
// source http://jsbin.com/rikoku
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script id="jsbin-javascript"> | |
| function World (name) { | |
| // Store the property. | |
| this.name = name; | |
| } | |
| // Define a class method. | |
| World.prototype.getName = function () { | |
| // Return the name property. | |
| return (this.name); | |
| }; | |
| // -------------------------------------------------- // | |
| // -------------------------------------------------- // | |
| function SubWorld () { | |
| // Invoke the custom constructor, passing in any | |
| // arguments that were provided. | |
| var f = World.apply(this, arguments); | |
| } | |
| SubWorld.prototype = World.prototype; | |
| SubWorld.prototype.subModule = { | |
| url: 'http://www.test.com', | |
| getUrl: function () { | |
| return this.url; | |
| } | |
| }; | |
| var subWorld = new SubWorld('Test'); | |
| console.log(subWorld.getName()); | |
| console.log(subWorld.subModule.getUrl()); | |
| </script> | |
| <script id="jsbin-source-javascript" type="text/javascript">function World (name) { | |
| // Store the property. | |
| this.name = name; | |
| } | |
| // Define a class method. | |
| World.prototype.getName = function () { | |
| // Return the name property. | |
| return (this.name); | |
| }; | |
| // -------------------------------------------------- // | |
| // -------------------------------------------------- // | |
| function SubWorld () { | |
| // Invoke the custom constructor, passing in any | |
| // arguments that were provided. | |
| var f = World.apply(this, arguments); | |
| } | |
| SubWorld.prototype = World.prototype; | |
| SubWorld.prototype.subModule = { | |
| url: 'http://www.test.com', | |
| getUrl: function () { | |
| return this.url; | |
| } | |
| }; | |
| var subWorld = new SubWorld('Test'); | |
| console.log(subWorld.getName()); | |
| console.log(subWorld.subModule.getUrl());</script></body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function World (name) { | |
| // Store the property. | |
| this.name = name; | |
| } | |
| // Define a class method. | |
| World.prototype.getName = function () { | |
| // Return the name property. | |
| return (this.name); | |
| }; | |
| // -------------------------------------------------- // | |
| // -------------------------------------------------- // | |
| function SubWorld () { | |
| // Invoke the custom constructor, passing in any | |
| // arguments that were provided. | |
| var f = World.apply(this, arguments); | |
| } | |
| SubWorld.prototype = World.prototype; | |
| SubWorld.prototype.subModule = { | |
| url: 'http://www.test.com', | |
| getUrl: function () { | |
| return this.url; | |
| } | |
| }; | |
| var subWorld = new SubWorld('Test'); | |
| console.log(subWorld.getName()); | |
| console.log(subWorld.subModule.getUrl()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment