Guest User

jellybeans

a guest
Jan 24th, 2026
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. class JellyBean {
  2. constructor() {
  3.  
  4. }
  5.  
  6. hop() {
  7. /* count a jellybean, add to aggregated total */
  8. }
  9. }
  10.  
  11. class RedJellyBean extends JellyBean {
  12. constructor() {
  13. super();
  14. }
  15.  
  16. hop() {
  17. Object.getPrototypeOf(Object.getPrototypeOf(this)).render() <----------------- QUESTION
  18. console.log("hop-scotch!");
  19. }
  20. }
  21.  
  22. const jelly = new RedJellyBean();
  23.  
  24. jelly.hop(); //traverse up the prototype chain, invokes `hop` on the RedJellyBean first
Advertisement
Add Comment
Please, Sign In to add comment