-
-
Notifications
You must be signed in to change notification settings - Fork 618
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
Add Concept Exercise: Windowing System (Classes) #1476
Conversation
Dear junedevThank you for contributing to the JavaScript track on Exercism! 💙
Dear Reviewer/Maintainer
Automated comment created by PR Commenter 🤖. |
6d7132d
to
ba2a7e9
Compare
@pertrai1 Please wait with the review until the PR is un-drafted/ready for review. I often rewrite the texts along the way. I only push to Github to make the status transparent and as a backup of the work. |
@SleeplessByte The about.md is done now, it was tough 😅, resources were similarly bad/fragmented as with type conversion. It would be great if you could review it. Please focus on whether something is wrong or something extremely important is missing (I know there is also more we could cover at some point). Also let me know in case you have written any good articles on the topic that I should link. I am neither an expert nor a fan of OPP, so please also check whether the terminology seems ok. @pertrai1 You can of course also review about.md now if you like. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great. Few suggestions.
Co-authored-by: Derk-Jan Karrenbeld <[email protected]>
@SleeplessByte Thanks again for the review of the concept content. I liked all the suggestions and applied the respective changes. I filled in the missing introduction files now that the about content was fixed so this is now ready to go once someone reviewed the rest. |
That means we can add fields to the new instance by adding them to `this` in the constructor function. | ||
|
||
```javascript | ||
function Car(color, weight) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it is helpful to show how this is constructed under the hood as an object:
function Car(color, weight) {
let thisObj = Object.create(null);
thisObj.color = color;
thisObj.weight = weight;
return thisObj;
}
this
removes the need to explicitly set the object and return it. Might be overkill or not needed :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the student might not know about Object.create
at this point, I felt this code is more confusing then helping. Imo the important part is that you don't have to explicitly return this
and that is covered in the text above.
this
is automatically returned from the constructor function ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds great @junedev. This concept looks awesome and enjoyed reading the code when reviewing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(fun fact, returning a new object from the constructor function is in fact a way to get closures/private variables and private functions from a constructor, however, you need to set the prototype at Object.create
if you want to keep inheritance to work)
Resolves #1015