Assing array value inside function
<html>
<head>
<script language="JavaScript">
<!--
var x = new Array();
function add(arrayName, value) {
var nextElement = arrayName.length;
arrayName[nextElement] = value;
}
x[0] = "1";
x[1] = "2";
x[2] = "3";
add(x, "new value!");
alert("The new value is: " + x[3]);
//-->
</script>
</head>
</html>
Related examples in the same category