1. 程式人生 > 其它 >javascript當中Array物件用法

javascript當中Array物件用法

javascript當中Array物件用法

1.Array物件

例 1.1

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
function sum(a)
{
var s = 0;
for (var i = 0; i < a.length; i++)
{
s = s + a[i];
}
return s;
}
var a = [4,2,3];
document.write(sum(a));

</script>
</head>
<body>
1) do sum through array 馬克-to-win
</body>
</html>



更多內容請見原文,文章轉載自:

https://blog.csdn.net/qq_43650923/article/details/102148517