隨機函數(隨機取數)

Math.random( )是隨機函數:隨機取0~1之間的任意數;javascript 一、四捨五入函數 若是是一位整數,那麼就要用到四捨五入函數:Math.round( ); 例如:css alert(Math.round(3.4));//3 alert(Math.round(3.5));//4 二、隨機0和1 alert(Math.round(Math.random()));//隨機取0或1
相關文章
相關標籤/搜索