Skip to content

Instantly share code, notes, and snippets.

@ricca509
Created November 3, 2014 21:57
Show Gist options
  • Select an option

  • Save ricca509/339d92d9b1d7c824077b to your computer and use it in GitHub Desktop.

Select an option

Save ricca509/339d92d9b1d7c824077b to your computer and use it in GitHub Desktop.
<!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>
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