Sunday 7 May 2017

Getting method name within the same method

For logging in some server side javascript, I had the need of getting the name of the method within the same method. There are 2 ways of doing this:
- accessing arguments.callee.toString() and applying regex extraction to get the name
- accessing arguments.callee.name

It does not always work though. ECMA strict mode does not allow it but their is no alternative either.