Chapter 4. Working with Numbers and Math
2010/07/31(土) 25:19 Javascript親記事へこのエントリーをはてなブックマークに追加

4.3  Creating a Random Number Generator

ランダム値の生成
Math.random()は0 以上 1 未満の値を生成する。
生成したランダムな値を Math.floorで繰り下げた整数を返すので、0から0.9の値ができる。
繰り上げの場合はMath.roundを使うけど紛らわしい。
Math.randomは厳密なランダムではない気がする。
var randomNumber = Math.floor(Math.random() * 255);// 0- 255の数字
var randomNumber = Math.floor(Math.random() * 6) + 5; // 5-10

4.6  Summing All Numbers in a Table Column

parseInt と parseFloat
document.querySelectorAllが初登場

4.8  Find the Radius and Center of a Circle to Fit Within a Page Element

SVGが初登場

いや書くことが無かった。

名前:  非公開コメント   

  • TB-URL  http://efcl.info/adiary/053/tb/