代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>demo</title>
</head>
<body>
<script>
var x;
var mycars = new Array();
mycars[0] = "BMW";
mycars[1] = "Changan";
mycars[2] = "futian";
for (x in mycars) {
document.write(mycars[x] + "<br/>");
}
</script>
</body>
</html>
效果: