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

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

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

我們先來看一下min函數(shù)的基本語法

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

 

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

我們下面來看具體示例

代碼如下

參數(shù)是正數(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

沒有參數(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

當參數(shù)中有參數(shù)無法轉(zhuǎn)換為數(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)文章

最新評論