欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS中min函數(shù)實(shí)例講解

 更新時(shí)間:2019年02月18日 08:46:23   投稿:laozhang  
在本文里我們給大家分享了關(guān)于JS中min函數(shù)的實(shí)例用法以及相關(guān)知識(shí)點(diǎn),需要的朋友們學(xué)習(xí)下。

我們先來(lái)看一下min函數(shù)的基本語(yǔ)法

Math.min(value1,value2,...)

 

Value1,Value2,……:傳遞到math.min()函數(shù)的值,用于查找最小值。

我們下面來(lái)看具體示例

代碼如下

參數(shù)是正數(shù)和負(fù)數(shù)時(shí):

代碼如下

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title></title>
</head>
<body>
<script type="text/javascript">
  document.write("Output : " + Math.min(10, 32, 2)); 
 document.write("Output : " + Math.min(-10, -32, -1));    
</script>
</body>
</html>

執(zhí)行結(jié)果如下:

Output : 1
Output : -32

沒(méi)有參數(shù)傳遞時(shí)

代碼如下:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title></title>
</head>
<body>
<script type="text/javascript">
 document.write("Output : " + Math.min());    
</script>
</body>
</html>

執(zhí)行結(jié)果如下

Output : -Infinity

當(dāng)參數(shù)中有參數(shù)無(wú)法轉(zhuǎn)換為數(shù)字時(shí):

代碼如下

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title></title>
</head>
<body>
<script type="text/javascript">
  document.write("Output : " + Math.min(10,2,NaN));    
</script>
</body>
</html>

執(zhí)行結(jié)果如下

Output : NaN

相關(guān)文章

最新評(píng)論