Math.round(n) 是返回四舍五入的n的值 match.random() 是返回0,1之间的随机数字 ---------------------random Returns a pseudo-random number between 0 and 1. The random number generator is seeded from the current time, as in Java. 方法源 Math 静态 实现版本 Navigator 2.0, LiveWire 1.0: Unix only Navigator 3.0, LiveWire 1.0: all platforms 语法 random() 参数 无。描述 Because random is a static method of Math, you always use it as Math.random(), rather than as a method of a Math object you created.示例 //Returns a random number between 0 and 1 function getRandom() { return Math.random() } round Returns the value of a number rounded to the nearest integer. 方法源 Math 静态 实现版本 Navigator 2.0, LiveWire 1.0 语法 round(x) 参数 x A number 描述 If the fractional portion of number is .5 or greater, the argument is rounded to the next highest integer. If the fractional portion of number is less than .5, the argument is rounded to the next lowest integer. Because round is a static method of Math, you always use it as Math.round(), rather than as a method of a Math object you created. 示例 //Displays the value 20 document.write("The rounded value is " + Math.round(20.49)) //Displays the value 21 document.write("<P>The rounded value is " + Math.round(20.5)) //Displays the value -20 document.write("<P>The rounded value is " + Math.round(-20.5)) //Displays the value -21 document.write("<P>The rounded value is " + Math.round(-20.51)) In server-side JavaScript, you can display the same output by calling the write function instead of using document.write. ----------------------------- 偶觉得实践最好,我买的JS书籍不多,网上的参考手册很不错的.javascript参考手册,DHTML手册等等.可以这里看别人的问题嘛,问题你会的的话解决一下,不会的话也试式,别人解决了,你看看不就提高了?
1表示true -1表示false
比如上面的你先要查Match.round是什么,match.random()是什么,至于return是返回值.引用它的地方需要该方法返回的值,返回1去处理什么,返回-1又去处理什么.....
是返回四舍五入的n的值
match.random()
是返回0,1之间的随机数字
---------------------random
Returns a pseudo-random number between 0 and 1. The random number generator is seeded from the current time, as in Java.
方法源 Math
静态
实现版本 Navigator 2.0, LiveWire 1.0: Unix only
Navigator 3.0, LiveWire 1.0: all platforms 语法
random()
参数
无。描述
Because random is a static method of Math, you always use it as Math.random(), rather than as a method of a Math object you created.示例
//Returns a random number between 0 and 1
function getRandom() {
return Math.random()
}
round
Returns the value of a number rounded to the nearest integer.
方法源 Math
静态
实现版本 Navigator 2.0, LiveWire 1.0 语法
round(x)
参数
x A number 描述
If the fractional portion of number is .5 or greater, the argument is rounded to the next highest integer. If the fractional portion of number is less than .5, the argument is rounded to the next lowest integer.
Because round is a static method of Math, you always use it as Math.round(), rather than as a method of a Math object you created.
示例
//Displays the value 20
document.write("The rounded value is " + Math.round(20.49)) //Displays the value 21
document.write("<P>The rounded value is " + Math.round(20.5)) //Displays the value -20
document.write("<P>The rounded value is " + Math.round(-20.5)) //Displays the value -21
document.write("<P>The rounded value is " + Math.round(-20.51)) In server-side JavaScript, you can display the same output by calling the write function instead of using document.write.
-----------------------------
偶觉得实践最好,我买的JS书籍不多,网上的参考手册很不错的.javascript参考手册,DHTML手册等等.可以这里看别人的问题嘛,问题你会的的话解决一下,不会的话也试式,别人解决了,你看看不就提高了?
if(-1) if (1) 条件为真