console.warn( "nothing selected, can't validate, returning nothing" );瀏覽器
單獨運行,竟然在控制檯打印出了nothing selected, can't validate, returning nothing,工具
豁然開朗,既然能夠這樣在控制檯打印出消息,那之後就免得麻煩去用什麼alert或是按F10去逐行調試了,確定能夠節省很多時間。spa
特地使用for(var i in console)查看了下各類瀏覽器控制檯對console的支持,以下插件
IE控制檯
log info warn error assert dir clear profile profileEnd
Firebug控制檯
log info warn error debug exception assert dir dirxml trace group groupEnd groupCollapsed time timeEnd profile profileEnd count clear table notifyFirebug firebug
Chrom控制檯
profiles memory debug error info log warn dir dirxml trace assert count markTimeline profile profileEnd time timeEnd group groupCollapsed groupEnd
Opera控制檯
debug
time timeEnd trace profile profileEnd debug log info warn error assert dir dirxml group groupCollapsed groupEnd count table 調試
能夠看出,四種瀏覽器對log、info、warn、error四個基本方法都是支持的,除了IE,其餘三種還支持個debug,因此使用debug要注意,固然咯,平時打印調試什麼的,用log就行。還有個問題,IE6/7沒有開發人員工具,也就沒有控制檯,而FF自己也是不帶控制檯的,須要加載Firebug插件而且啓動它,才能console,不然就是js報錯了。orm