AI

Sometimes you want to borrow a function and use it on a different object. call() and apply() let you explicitly set what this refers to.

Your Task:

  • We have a wizard object and a warrior object
  • wizard has a castSpell method
  • Use call() to make the warrior cast the spell! wizard.castSpell.call(...)
  • Pass 'Fireball' as the argument
TypeScript Solution
Loading...

Submit your code to see test results