<!doctype html> <html> <head> <meta charset="utf-8"> <title>js中字符串与数组的相互转换</title> </head> <body> <script type="text/javascript"> //javascript数组转换为字符串: /*var arr=new Array('百度','新浪','淘宝','京东'); document.writeln(arr.join(','));//输出:百度,新浪,淘宝,京东*/ //javascript字符串转换为数组: var str='百度,新浪,淘宝,京东'; console.log(str.split(','));//输出:["百度", "新浪", "淘宝", "京东"] </script> </body> </html>