You need to use the profiler; I recommend Chrome's. In the profiler the steps are
- Go to the profile part of the developer tools
- Get to the part where the slow js is
- Start recording
- Start the suspect code
- Stop recording
After that, the profiler will tell you everything you want to know about how many objects there are, how much time is spent in each method, etc...
The procedure should be similar with Firebug on Firefox.