forked from chuanxshi/javascript-patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule6-clone-inheritance.html
More file actions
36 lines (30 loc) · 923 Bytes
/
module6-clone-inheritance.html
File metadata and controls
36 lines (30 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!doctype html>
<html lang="en">
<head>
<title>JavaScript Patterns</title>
<meta charset="utf-8">
</head>
<body>
<script>
/* Title: Module Pattern - clone and inheritance Augmentation
Description: This pattern import modules, and add properties, then export it. It has adventage for developing large applications. And the new module object will inheritance the old one.
*/
var MODULE_TWO = (function (old) {
var my = {},
key;
// let my object inherience property
for (key in old) {
if (old.hasOwnProperty(key)) {
my[key] = old[key];
}
}
var super_moduleMethod = old.moduleMethod;
my.moduleMethod = function () {
// override method on the clone, access to super through super_moduleMethod
};
return my;
}(MODULE));
// Reference
// http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html
</script>
</html>