What are some real world uses for function.toString()?

Viewed 15089

I've noticed in JavaScript that if you define a function, say myfunction(), and then call myfunction.toString(), you get the text of the source for that function. Are there any interesting/real world uses of this?

15 Answers

toString is a serializer method. In some cases, we need to store function logic to storage such as database or transport via internet. It's also a kind of data to describe 'how to do something'.

Related