-
Notifications
You must be signed in to change notification settings - Fork 26
/
index6.js
69 lines (57 loc) · 1.13 KB
/
index6.js
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
// 構造函數 function
// function createCard(initName) {
// this.name = initName
// }
// class的基本操作
// class Card {
// constructor(initName) {
// this.name = initName
// }
// }
// const c1 = new Card("布魯斯")
// console.log('c1', c1)
// console.log(c1.name);
// this
// class Card {
// constructor(initName) {
// this.name = initName
// // this
// // this.hellooo = this.hello.bind(this)
// }
// hello = () => {
// console.log("hello", this.name)
// }
// }
// const c1 = new Card("布魯斯")
// console.log('c1', c1)
// c1.hello()
// const a = { name: 'AA' }
// a.hellooooo = c1.hello
// a.hellooooo()
// 繼承
class Car {
constructor(initName) {
this.name = initName
}
start() {
// TODO del
console.log('車子啟動')
}
}
class Porshe extends Car {
constructor(namePorshe) {
super(namePorshe)
}
// start2() {
// super.start()
// console.log('車子排氣')
// }
// start() {
// super.start()
// console.log('porshe車子啟動')
// }
}
const p1 = new Porshe("布魯斯的保時捷")
p1.start()
// TODO del
console.log('name', p1.name)