JAVA AJAX教程第二章-JAVASCRIPT基础知识
2009-10-27 00:00:00 来源:WEB开发网12 创建数组
程序代码
<script language=”JavaScript”>
<!--
var myArray = new Array(5);
myArray[0] = “First Entry”;
myArray[1] = “Second Entry”;
myArray[2] = “Third Entry”;
myArray[3] = “Fourth Entry”;
myArray[4] = “Fifth Entry”;
var anotherArray = new Array(“First Entry”,”Second Entry”,”Third Entry”,”Fourth Entry”,”Fifth Entry”);
// -->
</script>
13 数组排序
程序代码
<script language=”JavaScript”>
<!--
var myArray = new Array(5);
myArray[0] = “z”;
myArray[1] = “c”;
myArray[2] = “d”;
myArray[3] = “a”;
myArray[4] = “q”;
document.write(myArray.sort());
// -->
</script>
14 分割字符串
程序代码
<script language=”JavaScript”>
<!--
var myVariable = “a,b,c,d”;
var stringArray = myVariable.split(“,”);
document.write(stringArray[0]);
document.write(stringArray[1]);
document.write(stringArray[2]);
document.write(stringArray[3]);
// -->
</script>
更多精彩
赞助商链接