Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class JellyBean {
- constructor() {
- }
- hop() {
- /* count a jellybean, add to aggregated total */
- }
- }
- class RedJellyBean extends JellyBean {
- constructor() {
- super();
- }
- hop() {
- Object.getPrototypeOf(Object.getPrototypeOf(this)).render() <----------------- QUESTION
- console.log("hop-scotch!");
- }
- }
- const jelly = new RedJellyBean();
- jelly.hop(); //traverse up the prototype chain, invokes `hop` on the RedJellyBean first
Advertisement
Add Comment
Please, Sign In to add comment