<script type= "Text/javascript" >//to find the largest number in an arrayvararr=[123,456,789,657,432,564];vararrmax=Getmaxvalue (arr); alert (Arrmax);functionGetmaxvalue (arrint) {varMax=arrint[0]; for(vari=0;i<arr.length;i++) { if(Arrint[i] >max) {Max=Arrint[i]; } } returnMax;}</script>
Results: 789
Array conversion to string
<script type= "Text/javascript" >var names=["Jing ke Long", "Greetings", "Time Words", "Search Dance", "Merry Christmas"]var named=getName (names); alert (named); function GetName (strName) { var str= ""; for (var i=0; i<strname.length;i++) { str=str+strname[i]+ "|" ; } return str.substring (0,str.length-1);} </script>
Results: Keio | greetings | time words | search Dance | Merry Christmas
// Remove object group with ID 1 <script type= " Text/javascript "> var modjson=[{id:" 1 ", Name:" Wwee ", Addr:" 3qw "},{id:" 2 ", Name: "User", addr: "KKK"},{id: "3", Name: "We42", Addr: "23ds" for (var i = 0; i < Modjson.length; I++ if (modjson[i].id = = 1 1); // }} Console.info (Modjson); </script>
// Array _ Order rollover <script type= "Text/javascript" >var names=["Keio", "Greetings", "Time Words", "Search Dance", "Huahua" GetName (names); alert (names); function GetName (strName) { var str; for (var i=0; i<strname.length/2;i++) { str=strname[i]; Strname[i]=strname[strname.length-1-i]; Strname[strname.length-1-i]=str; } } </script>
The results are: Huahua, search for dance, time, greeting, Beijing-Silom
//usage of for and in<script type= "Text/javascript" >varmycars=NewArray ("Any", "Mlik", "Yli");varmycars1=NewArray ("DF", "W3", "FGF"); for(vari=0;i<mycars.length;i++) {document.write (Mycars[i]+ "<br/>");} for(xinchmycars1) {document.write (mycars1[x]+ "<br/>")}document.write (Mycars.concat (mycars1) )//The concat () method is used to concatenate two or more arrays. </script>
Results:
Any
Mlik
Yli
Df
W3
Fgf
Any,mlik,yli,df,w3,fgf
<script>varCaser=NewArray ("Who Am I", "who Are You", "who is he");//declaring a variable caser an array type for(vari=0;i<caser.length;i++) {document.write (Caser[i]+ "<br>"); } varunn=NewArray (); varJ; unn[0]= "123"; unn[1]= "456"; unn[2]= "789"; for(j=0; j<unn.length;j++) {document.write (unn[j]); } </script>
An array of JavaScript basics