Skip to content

Commit

Permalink
Program4中的clonePlane改為planeInstance
Browse files Browse the repository at this point in the history
  • Loading branch information
Yu-Che-Gao committed Nov 25, 2016
1 parent 2ba9e72 commit 1485daa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ch1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ plane.blood = 500
plane.attackLevel = 10
plane.defenseLevel = 7

var clonePlane = Object.create(plane)
console.log('blood: ' + clonePlane.blood)
console.log('attackLevel: ' + clonePlane.attackLevel)
console.log('defenseLevel: ' + clonePlane.defenseLevel)
var planeInstance = Object.create(plane)
console.log('blood: ' + planeInstance.blood)
console.log('attackLevel: ' + planeInstance.attackLevel)
console.log('defenseLevel: ' + planeInstance.defenseLevel)
```

原型模式的關鍵在於本身是否提供clone方法,ES5提供Object.create來複製物件
Expand Down

0 comments on commit 1485daa

Please sign in to comment.