-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
completed first approach #451
Conversation
Hey! Congratulations on your PR! 😎😎😎 Let's do some self-checks to fix most common issues and to make some improvements to the code before reviewers put their hands on the code. Go through the requirements/most common mistakes listed/linked below and fix the code as appropriate. If you have any questions to requirements/common mistakes feel free asking them here or in Students' chat. When you genuinely believe you are done put a comment stating that you have completed self-checks and fixed code accordingly. Also, be aware, that if you would silently ignore this recommendation, a mentor can think that you are still working on fixes. And your PR will not be reviewed. 😒 A Tiny JS World -- (pre-OOP) exercise check listRelates to Object-Oriented JavaScript task. Check-list - definition of done
Universal recommendations:
Also take a note of the requirements above and follow them in all your future projects. By the way, you may proceed to the next task before this one is reviewed and merged. Sincerely yours, |
checked |
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.
Hey, what happened to your Catwoman O? Why is she so undefined. Define her or something. Jokes aside, there is a problem with her saying. Task asks you to make it so Catwoman says the same that cat says ANYTIME. But in your current implementation changing the cat's saying doesn't change Catwoman's one, does it?
hi! saying: cat.saying does work indeed) although i could've changed it by the means of inheritance (as i did here - https://github.com/sofiichuk/a-tiny-JS-world/blob/OOP-exercise/index.js). do i have to change anything yet? |
Well yes, your catwoman does say what the cat initially says, but that's why I marked ANYTIME in my comment. Consider this: const cat = { saying: "First test" };
const catwoman = { saying: cat.saying };
console.log(catwoman.saying) // this will be "First test"
cat.saying = "Second test";
console.log(catwoman.saying) // this should be "Second test", but with your implementation, it will still be "First test" So you need to find a way to connect those values in some way. And yes, for the means of this task, without using classes syntax. |
spent so much time... |
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.
GJ, it works, but please check my comment below and keep it in mind in the future.
friends: 'undefined' | ||
}; | ||
|
||
Object.setPrototypeOf(catWoman, cat); |
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.
This is the second time I see Object.setPrototypeOf
, did anyone tell you to use it? Specs say it is a very slow method and there is an alternative - Object.create()
. Or you could've used bind
. Anyway, keep these in mind.
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.
at first i tried to transform cat.saying to an object/array to pass it by reference;
then i tried to combine cat and catwoman props using object.assign;
i failed with both;
then i found out people handle stuff like this with a _proto_;
but i had already known of _proto_ as a (kind of) method not recommended to use in explicit way;
so i continued searchin for smth similar as a substitution;
nth-google-request was "set prototype" and it led to setPrototype;
(and now i see it's no better than using _proto_ - but afterwards)
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.
Got it, nice research)
a tiny js world: first approach
Demo |
Code base
The code is submitted in a dedicated feature branch.
Only code files are submitted.
Please, review.