PHP ZCE mock test, interview preparation, daily lessons under chalk talk

Thursday, November 15, 2012

javascript OR jquery - get the calling function code

We all know javascript is a messy language. There may be a time when you have to fix some frontend bug, and you are wandering around javascript code to know its flow.

One solution to this problem is using attributes of arguments property. Such as

1. alert(arguments.callee);

It will alert the code of the function from this alert is being called.

2. alert(arguments.callee.caller);

It will alert the code of the function from which function containing alert was called.


Its quite a helpful thing!!! now say thanks :P

No comments:

Post a Comment