在參考一些Javascript範例時,常看到console.log()的寫法,昨天才發現這又是一個被我忽略的好東西。在Firefox上,我們可以透過console.log()輸出一些Debug資訊,並使用Firebug檢視,跟.NET偵錯時的Debug.WriteLine()有異曲同工之妙!
jQuery.fn.log = function(msg) { if (typeof console != "undefined")
console.log("%s: %o", msg, this); return this;
};