Posts mit dem Label Debug werden angezeigt. Alle Posts anzeigen
Posts mit dem Label Debug werden angezeigt. Alle Posts anzeigen

Mittwoch, 7. Dezember 2011

All Methods from a Javascript Object

I wrote that little helper because webdeveloper toolbar didn't show all methods to me. Maybe it's useful for you too.

https://gist.github.com/1441816

Donnerstag, 1. Dezember 2011

console.log & debug flag?

Instead of checking the DEBUG flag everytime you need a debug info, like this:

    if (DEBUG) {
        console.log("my debug output");
    }

you can just check the DEBUG flag once and disable the console.log function, like this:

    if (DEBUG === false) {
        console = {
            log: function() {}
        };
    }

This enables you to simply call:

    console.log("my debug output")

in your application. If DEBUG is true, you'll get your output. If DEBUG is false, console.log() will be called but is an empty function and thus will produce no output / error.