<!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=gb2312" />
<title>js
字符串转换为数组与数组转换成字符串</title>
<script language="
javascript">
function arraytostr() //数据转换成字符串函数
{
var array = new array('1',2,3,4,5,6,7,8,9);
var str = array.join("-");
document.write(str);
}
function strtoarray() //字符串转换数组函数
{
var str ='1,2,3,www.dgjs123.com,mb.dgjs123.com';
document.write(str.split(','));
}
</script>
</head>
<body>
array('1',2,3,4,5,6,7,8,9);
<a href="javascript:arraytostr();">转换字符串</a><br />
输了 1-2-3-4-5-6-7-8-9
<br />
var str ='1,2,3,www.dgjs123.com,mb.dgjs123.com';
<a href="javascript:strtoarray();">转换数组</a><br />
输出 1,2,3,www.dgjs123.com,mb.dgjs123.com
</body>
</html>