亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

JS數(shù)組的常見用法實(shí)例

 更新時(shí)間:2015年02月10日 09:47:16   作者:woshisap  
這篇文章主要介紹了JS數(shù)組的常見用法,實(shí)例分析了javascript針對(duì)數(shù)組的遍歷、排序與字符串分割成數(shù)組等用法,非常具有實(shí)用價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了JS數(shù)組的常見用法。分享給大家供大家參考。具體方法如下:

復(fù)制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>數(shù)組方法的應(yīng)用</title> 
<script type="text/javascript"> 
   var arrayFruit = new Array("apple", "orange", "peach", "bannaner"); 
   document.write("排序前的數(shù)組 <br/>"); 
   for(var i in arrayFruit) { 
       document.write(arrayFruit[i] + "<br />"); 
   } 
   arrayFruit.sort();  //對(duì)數(shù)組進(jìn)行排序 
   document.write("排序后的數(shù)組:<br />"); 
   for(var i in arrayFruit) { 
       document.write(arrayFruit[i] + "<br />"); 
   } 
   document.write("排序后連接的字符串:<br />"); 
   var str = arrayFruit.join("-"); 
   document.write(str); 
    var strFruit = "apple,bannaner,orange,peach"; 
    var tempFruit = strFruit.split(","); 
    document.write("字符串分割成的數(shù)組<br />"); 
    for(var i in tempFruit) { 
       document.write(tempFruit[i] + "<br />"); 
   } 
</script> 
</head> 
<body> 
</body> 
</html>

主要介紹數(shù)組的遍歷和字符串的分割,感興趣的朋友可以測(cè)試運(yùn)行一下。

希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論