-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8-5.js
More file actions
31 lines (30 loc) · 934 Bytes
/
8-5.js
File metadata and controls
31 lines (30 loc) · 934 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
/*建立Function的命名空間,在js檔被調用時就會註冊到當下環境*/
var extend = (function() {
for(var p in {toString:null}){
return function extend(o){
for(var i = 1; i < arguments.length; i++){
var source = argments[i];
for(var prop in source) o[prop] = source[prop];
}
return o;
};
}
return function patched_extend(o){
for(var i = 1; i < arguments.length; i++){
var source = arguments[i];
for(var prop in source) o[prop] = source[prop];
//
for(var j = 0; j < protoprops.length; j++){
prop = protoprops[j];
if (source.hasOwnProperty(prop)) o[prop] = source[prop];
}
}
return o;
};
var protoprops = ["toString", "valueOf", "constructor", "hasOwnProperty",
"isPrototypeOf", "propertyIsEnumerable", "toLocaleString"];
}());
function TestExtend(){
//var a = extend();
alert(extend);
}