JavaScript数组对象赋值使用实例源码,这里JavaScript数组对象的使用会使你的JS程序变得简洁而有效率,但是好像不少新手都不喜欢用数组,因为觉得它们抽象,不好理解,其实只要你认真领悟,它就像捅破窗户纸一样,令你豁然开朗。
运行效果图如下:
具体代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
<html> <head> <meta http-equiv= "content-type"
content= "text/html; charset=GB2312"
/> <title>Js数组对象方法应用示例</title> </head> <body style= "overflow:auto;" > <div style= "font-size:12px; font-weight:bold; color:white; font-family:Arial, 宋体; background-color:#6090DA; padding:4px 10px;" > <script type= "text/javascript" > var
user_inputs = new
Array(); var
str; while (str=prompt( "请输入任意内容:" , "" ))user_inputs.push(str); user_inputs.sort(); document.write( "你输入的内容排序后的结果为:<br>" +user_inputs.join( "<br>" )); </script> </div> </body> </html> |