-
Notifications
You must be signed in to change notification settings - Fork 0
/
constructer.html
77 lines (64 loc) · 1.42 KB
/
constructer.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
<script>
/*function user(name,age){
this.name=name;
this.age=age;
this.isAdmin="false";
}
let user=new user("koushik");
let user=new user(29);
alert(user.name);
alert(user.age);
alert(user.isAdmin);
/* alert("hello!");
}
User();*/
/*function User(){
alert(new.target);
}
User();
new User();*/
/*function BigUser(){
this.name="koushik";
return {name:"tony"};//returns an object
}
alert( new BigUser().name);*/
/* this.name="john";
return;
}
alert(new SmallUser().name);*/
/*function User(name){
this.name=name;
//declaring a method
this.hi=function(){
alert("my name is : "+this.name);
};
}
let User= new User("tony");
alert(User.name);*/
/*function Calculater(){
this.read=function(){
this.a=+prompt('a?',0);
this.b=+prompt('b?',0);
};
this.sum=function(){
return this.a+this.b;
}
this.mul=function(){
return this.a*this.b;
};
}
let calculater= new Calculater();
calculater.read();
alert("the sum : "+calculater.sum());
alert("the multi: "+calculater.mul());*/
function Accumulater(startingvalue){
this.value=startingValue;
this.read=function(){
this.value+=+prompt('how much to add?',0);
};
}
let accumulater= new Accumulater(1);
accumulater.read();
accumulater.read();
alert(accumulater.value);
</script>