You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was not able to take the line Player.super_.prototype.toString.call(this) and convert it to super.toString();. I had to pull up the solution. I've still got a way to go before I completely understand what's happening in Exercise 3, but is there a way the instructions could be written so it's slightly more obvious how to rewrite this line?
Additionally, it makes sense to make that we wouldn't need to include util since we rewrote that line, but how would I have known to start the script with 'use strict';?
The text was updated successfully, but these errors were encountered:
Just passing by to contribute: trying to disect the line you wrote just by programmer's instinct, we can deduce that the expression is trying to:
Player: get the player object
.super_: access the 'superclass'
.prototype: but the class stuff (methods and the like) really lives in its prototype
.toString: we access that superclass string method
.call(this): and we try to use it on the actual object (by the expression context, it's the player)
So, resuming, we are just trying to use the superclass string method here in this context (the Player's context... again, on instinct, we could have come up with the solution super.toString(). Maybe a small hint on saying exactly that ('remember we are just trying to use the superclass string method') could prove useful.
Regarding the 'use strict';, it doesn't affect the correctness of the answer, but its considered a good practice to add it to every JS code you can. It basically tells the JS engine to not forgive sloppy code making it more robust and even secure. You can read a little more of it here on MDN
I was not able to take the line
Player.super_.prototype.toString.call(this)
and convert it tosuper.toString();
. I had to pull up the solution. I've still got a way to go before I completely understand what's happening in Exercise 3, but is there a way the instructions could be written so it's slightly more obvious how to rewrite this line?Additionally, it makes sense to make that we wouldn't need to include
util
since we rewrote that line, but how would I have known to start the script with'use strict';
?The text was updated successfully, but these errors were encountered: