-
Notifications
You must be signed in to change notification settings - Fork 0
/
JavaScript.html
106 lines (102 loc) · 2 KB
/
JavaScript.html
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html>
<head>
<title>JavaScript</title>
</head>
<body>
<script>
//arguments.callee 调用本身
function factoial(num)
{
if(num<=1){
return 1;
}else{
return num*arguments.callee(num-1);
}
}
//call and apply
var jack={job:"HR",salary:"6000"};
var rose={job:"IT",salary:"9000"};
var job="Car Driver";
var salary="4800";
var Staff={job:"hunter",salary:"1350"};
Staff.myJob=function(){
//console.info("My job is "+this.job+". My salary is $"+this.salary);
}
Staff.myJob.call(this);
Staff.myJob.call(jack);
Staff.myJob.call(rose);
Staff.myJob();
//arguments
function sum(){
var sum=0;
for(var k in arguments){
if(typeof arguments[k] == "number"){
sum+=parseFloat(arguments[k]);
}
}
return sum;
}
//console.info(sum(1,2,3,'a',4));
var p={
sum:function(){
return 100;
}
}
for(var k in p)Math[k]=p[k];
function info(msg){
console.info(msg);
}
function avg(){
return 20;
}
//匿名函数
(function(name,job){
var job="Teacher";
var salary="4000";
//console.info(Math.sum());
//console.info("My name is "+name+". My job is "+job);
/*function avg(){
return 10;
}*/
})("jack","COO");
function Staff_IT(){
var s=this;
s.skills =["AS3.0","JS","PHP"];
s.level="seior";
s.info={name:'',age:'',sex:'',address:'',phone:'',level:s.level,skills:s.skills};
}
Staff_IT.prototype={
getSkills:function(){
return this.skills;
},
getInfo:function(){
return this.info;
},
setInfo:function(info){
for(var k in info)this.info[k]=info[k];
}
};
var it=new Staff_IT();
it.setInfo({name:"jack"});
var manifest=[
{name:"albe",glade:"Senior One",age:"16",sex:"male"},
{name:"amamd",glade:"Senior One",age:"16",sex:"male"},
{name:"bill",glade:"Senior One",age:"16",sex:"male"},
{name:"Lily",glade:"Senior One",age:"16",sex:"female"},
{name:"olioy",glade:"Senior One",age:"16",sex:"male"}
];
function Student(){
var s=this;
s.loadManifest=function(manifest){
for(var k in manifest){
var o=manifest[k];
info(o);
}
}
}
var student=new Student();
student.loadManifest(manifest);
</script>
</body>
</html>