-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path2.Object.js
More file actions
46 lines (37 loc) · 801 Bytes
/
2.Object.js
File metadata and controls
46 lines (37 loc) · 801 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
37
38
39
40
41
42
43
44
45
/**
* Created by Think on 2016/7/3.
*/
/**
* 面向对象编程
* @param name
* @param age
*/
function person(name,age){
this.name = name;
this.age = age;
}
/*
function r(t) {
return t.toLowerCase().replace(/[xy]/g, function (t) {
var n = 16 * Math.random() | 0, r = "x" == t ? n : 3 & n | 8;
return r.toString(16)
}).toUpperCase()
}
console.log( r("xxx"));*/
/**
* 枚举n对象的属性,如果n对象中的属性为自有属性(非继承),将属性定义为t的原型。
* @param t t
* @param n
*/
function n(t, n) {
var r;
//for (r in n)n.hasOwnProperty(r) && (t.prototype[r] = n[r])
for (r in n){
n.hasOwnProperty(r);
(t.prototype[r] = n[r]);
}
}
var a = { a:5};
var b = { b:15};
n(a,b);
//console.log(a.b);