var id=null;var random= Math.random();if(random< 0.1) id= 0;else if(random< 0.3) id= 1;else if(random< 0.35) id= 2;else if(random< 0.65) id = 3else if(random< 0.7) id = 4;else if(random< 0.75) id= 5;else if(random< 0.8) id= 6;else if(random< 0.9)id= 7;else if(random< 0.95)id= 8;else if(random< 1) id= 9;alert(id)
当0<=random<0.1(区间跨度0.1) id = 0;当0.1<=random<0.3(区间跨度0.2) id = 1;当0.3<=random<0.35(区间跨度0.05) id = 2;当0.35<=random<0.65(区间跨度0.3) id = 3;当0.65<=random<0.7(区间跨度0.05) id = 4;当0.7<=random<0.75(区间跨度0.05) id = 5;当0.75<=random<0.8(区间跨度0.05) id = 6当0.8<=random<0.9(区间跨度0.1) id = 7当0.9<=random<0.95(区间跨度0.05) id = 8当0.95<=random<1(区间跨度0.05) id =9