-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclass.js
More file actions
58 lines (48 loc) · 1.29 KB
/
class.js
File metadata and controls
58 lines (48 loc) · 1.29 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
class Clock {
constructor({ template }) {
this.template = template
}
render() {
let date = new Date()
let hours = date.getHours()
if (hours < 10) hours = '0' + hours
let mins = date.getMinutes()
if (mins < 10) mins = '0' + mins
let secs = date.getSeconds()
if (secs < 10) secs = '0' + secs
let ms = date.getMilliseconds()
if (ms < 10) {
ms = "00" + ms
} else if (ms < 100) {
ms = '0' + ms
}
let output = this.template
.replace('h', hours)
.replace('m', mins)
.replace('s', secs)
.replace('ms', ms)
// console.log(output)
document.body.innerHTML = output
}
stop() {
clearInterval(this.timer)
}
start() {
this.render()
this.timer = setInterval(() => this.render(), 1000)
// document.body.append(output)
}
}
let clock = new Clock({ template: 'h:m:s' })
// clock.start()
// clock.stop()
class Rabbit {
constructor(name) {
// super()
this.name = name;
}
static __proto__ = Object.prototype
}
let rabbit = new Rabbit("Кроль");
// console.log(rabbit.hasOwnProperty('name'));
// console.log(Rabbit.prototype.__proto__)