Adding Deprecation Warning in JavaScript Console

I used this quick trick today to help me clean up and refactor some javascript functions today:

if ("console" in window) console.warn('DEPRECATED function call to '+ arguments.callee +'\nCalled by:\n'+ arguments.callee.caller );

Which results in a fine deprecation warning in the console:

There is plenty of space for improvement here. Feel free to use or tamper … but please post any alternative suggestions here as a comment.

2 Responses to “Adding Deprecation Warning in JavaScript Console”

  1. Mick Staugaard Says:

    That’s a really neat little trick! Thanks for sharing Jesper.

  2. Tobias Says:

    If you want to get the console output in Internet Explorer, you can install the Companion.JS plug-in:
    http://www.my-debugbar.com/wiki/CompanionJS/HomePage