Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
zoz
· 11y ago · 0 comments
I was a little confused by the constructor for Player in the class example. Wouldn't the following be more appropriate:
constructor(x = 0, y = 0) { this.x = x; this.y = y; }
(i.e. this way if "new Archer('Legolas', 5, 6);" the x and y values will not be ignored.)
Comments
[–]
niix
11y ago
Sure that works too, plus its a great way to point out initializing default arguments.