toString() Hooking

Published by MWO in

You have one job and one job only, to ruin the day of any unsuspecting victim using the toString() function. Hook the String prototype toString() to instead return a string that is in reverse.

Examples

("Hello World!").toString() ➞ "!dlroW olleH"

("My hooking function! :3").toString() ➞ "3: !noitcnuf gnikooh yM"

("RaceCar").toString() ➞ "raCecaR"

Notes

Remember that this is an object!

Watch a quick demo on how Edabit works.