New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
oojs/assessment: Shape constructor should take arguments #7
Comments
Argh, dammnit - my brain was out to lunch when I wrote this one ;-| So, I have updated the call() description in this article: So that it hopefully makes more sense as to what it is doing. I have also updated the description of the bouncing balls in the assessment: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Adding_bouncing_balls_features And updated the code examples: https://github.com/mdn/learning-area/blob/master/javascript/oojs/assessment/main.js So I've kinda gone the opposite way here - removing the need for arguments altogether. I still think this is useful to show how a constructor can create an entire object with just a single line of code, even if the attributes are random rather than user defined. I guess the best practice would be to have the values taken from the parameters rather than being just random, so the caller could decide to create an object of fixed or random size? |
I've updated the examples and text again, to take the random calls out of the constructor and into the instantiation calls. |
Thanks for the quick response! |
See http://stackoverflow.com/questions/43785607/inheritance-of-properties-through-passing-constructor-parameters
In general it is a good practise not to perform side effects (
random
) in constructors, but let the caller who creates the object do this.The text was updated successfully, but these errors were encountered: