-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex3.html
More file actions
199 lines (156 loc) · 3.3 KB
/
index3.html
File metadata and controls
199 lines (156 loc) · 3.3 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
// var obj = {};
// var obj_2 = new Object();
/* student.name = 'Alex';
student.course = 'JavaScript';
student.course_part = 3;
student['Адрес'] = 'г. Киев, улю Арсенальная, 5';*/
/* var student = {
name: 'Alex',
course: 'JavaScript',
courses_learned: ['HTML', 'CSS', 'Wordpress']
};
/* console.log(student.courses_learned);
console.log('Student '+student.name+' learns '+student.course);*/
/* if ('name' in student) console.log(student.name)
else console.error('not find')
var courser_q = 0;
for (var i in student) {
if (i === 'courses_learned') {
var courser_q = student[i].length;
student.courses_q = courser_q;
}
console.log(i+':'+student[i]);
}
console.log(student);*/
/* var student = [
{
name: 'Alex',
age: 18
}, {
name: 'Mark',
age: 30
}, {
name: 'Eva',
age: 16
}, {
name: 'Andre',
age: 19
}
];*/
/* var sortByAge = {
'18+': [],
'до 18': []
};
console.log(student, sortByAge);
for (var i=0; i<student.length; i++) {
student[i].age>=18 ? sortByAge['18+'].push(student[i]) : sortByAge['до 18'].push(student[i]);
}
console.log(sortByAge);*/
// delete student[0].name;
// console.log(student);
/* var student = {
name: 'Alex',
age: 18
};
var student_copy = Object.assign(student, {courses: 'JS'});
console.log(student, student_copy);*/
/* var student_copy = {};
for (var i in student) {
student_copy[i]=student[i];
}
student_copy.name = 'Mark';
console.log(student, student_copy);
*/
/* function sum(a,b){
console.info(a);
return a+b;
};
sum(2,2);*/
/*
var summ=function(a,b){
return a+b;
};
function doSmth (a,b,func){
return func(a,b);
};
var elSumm = doSmth(2,5,summ);
console.log(elSumm);
*/
/* var timer = setInterval(function(){
console.log('Hello');
}, 200);
console.log(timer);
setTimeout(function(){clearInterval(timer)}, 10000);*/
/* var student = {
name: 'Alex',
sayHi: function(name){
console.log('Hi from '+this.name+' '+name);
}
};
student.sayHi('Alisa');
student.sayHi('Mark');*/
/* function student(name, course){
console.log(this);
};
student();
this.a = '2'; */
// ПРИНЦИП МОДУЛЬНОСТИ
/*(function(){
var a='2';
console.log(a);
})();
var a='2';*/
/* function Student(name, course) {
this.name = name;
this.course = course;
};
Student.prototype.sayHi = function(){
console.log('Hi, I am '+this.name+'!');
}
Student.prototype.changeName = function(name) {
this.name = name;
console.log('Name change to '+name);
}
var vasiliy = new Student ('Vasya', 'JS'),
anna = new Student ('Anna', 'CSS3');
console.log(vasiliy, anna);
vasiliy.sayHi();
anna.sayHi();
vasiliy.changeName('Gena');
vasiliy.sayHi();*/
var studentTalk = {
sayHi: function(){
console.log('Hi, I am '+this.name+'!')
},
sayBye: function(){
console.log('Bye, from '+this.name+'!')
}
}
var vasya = {
name: 'Vasya',
age: 30,
}, natasha = {
name: 'Natasha',
age: 20,
}
vasya.__proto__ = studentTalk;
natasha.__proto__ = studentTalk;
vasya.sayHi();
vasya.sayBye();
natasha.sayHi();
natasha.sayBye();
function summ() {
console.log(arguments);
}
summ(2,2,3,23,54,5,55,5);
</script>
</body>
</html>