これはひどい

生意気な後輩に「これはひどい」って言われた。自分でもわかってるけどさ。

Debug.log = function(msg) {
  if (!Debug.ENABLED)
    return;
  try { GM_log(msg); return } catch(e) {}
  try { console.log(msg); return } catch(e) {}
  try { WScript.Echo(msg); return } catch(e) {}
  try { alert(msg); return } catch(e) {}
  try { print(msg); return } catch(e) {}
}


ちなみに彼のコードはこんな風だった。

function debug(msg) {
  alert(msg);
//  WScript.Echo(msg);
}

ちょw。

typeof でチェックするのが正解なのかなぁ。なんかのライブラリ覗けばあるかな。