granmirupa granmirupa - 1 year ago 43
Javascript Question

JavaScript: How can I get code as String?

I have this object:

{ tag: 'button',
attrs: { onClick: this.myFunc },
children: 'Name' }

This object is in a context where
is a function.
How can I get

If I try with:
it prints all of the function:


Answer Source

Have you tried this to get the function name as a string;

This would most likely return "myFunc" and not "this.myFunc" though, just depends what you want.