成都网站建设|域名注册|虚拟主机|网站制作|网站案例|网站优化|网站推广|企业邮局|服务器租用|广告设计
本文实例讲述了JS交换变量的方法。分享给大家供大家参考。具体实现方法如下:
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript"> function jh(arr) { for (var i = 0; i < arr.length / 2; i++) { var tem = arr[i]; arr[i] = arr[arr.length -i - 1]; arr[arr.length -i - 1] = tem; } } var names = new Array(); names[1] = "tom"; names[2] = "lily"; names[3] = "jek"; jh(names); alert(names); </script> </head> <body> </body> </html>