代码编辑器:
x
1
<p id="demo">点击按钮将数组转为字符串并返回</p>
2
<button onclick="myFunction()">点我</button>
3
<script>
4
function myFunction(){
5
var fruits = ["Banana", "Orange", "Apple", "Mango"];
6
var str = fruits.toString();
7
var x=document.getElementById("demo");
8
x.innerHTML= str;
9
}
10
</script>
11