Archive for the ‘Javascript’ Category:

Firebug API

{ Posted on 二 23 2009 by Xiacong }
Categories : Javascript
用Firefox加载的页面,Firebug都添加了一个全局变量console,通过这个变量的若干方法,你可以通过脚本向控制台输出各种调试信息。 console.log(object[, object, ...]) 往控制台写一条信息,可以有多个参数,甚至可以像printf那样格式化出去,例如 console.log("The %s jumped over %d tall buildings", animal, count); 或者这样: console.log("The", animal, "jumped over", count, "tall buildings"); console.log("I am %s and I have:", myName, thing1, thing2, thing3); 下面是格式化参数表: String Substitution Patterns %s String %d, %i Integer (numeric formatting is not yet supported) %f Floating point number ...Read More »

循环的效率

{ Posted on 七 31 2008 by Xiacong }
Categories : Javascript
三种循环方式: var i = 100000; do{}while(i--);//第一种循环方式 for(var i=100000;i>0;i--){}//第二种循环方式 for(var i=0;i<100000;i++){}//第三种循环方式 第一种循环方式效率最高,比第三种循环方式快一倍左右、第二种循环方式比第三种循环方式略快; Read More »