Skip to content

Commit c891935

Browse files
committed
Create extend.js
1 parent 3a7051b commit c891935

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

extend.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Function that copies objects and their properties.
2+
// Doesn't work with prototypes.
3+
4+
function extend(parent, child) {
5+
var i;
6+
var child = child || {};
7+
for(i in parent) {
8+
if(parent.hasOwnProperty(i)) {
9+
child[i] = parent[i];
10+
}
11+
}
12+
return child;
13+
}

0 commit comments

Comments
 (0)