Hacker News new | ask | show | jobs
by mvclark 4413 days ago
Nice post. Another one I find useful is to define your own log function, e.g.,

function log(x) {console.log(x);};

You'd use log instead of console.log for debugging your code. Then, to turn off logging, you set

function log(x) {};

or have a boolean switch in log function to do a similar thing. You could even use this approach to define debug levels to enable/disable.