why is the following code showing undefined
? Are we not allowed to create an array with a single value? Putting two values won't show this error. Is this a problem with Javascript?
<script>
var tech = new Array(21);
alert(tech[0]);
</script>
why is the following code showing
| ||||
feedback
|
If you want to dynamically fill an array, use the
When the Array constructor receives one parameter
| |||||||||
feedback
|
The above example defining an array called tech with 21 positions. You have to difine it like that
| |||
feedback
|
by new Array(21) you're actually creating an array with 21 elements in it. If you want to create an array with single value '21', then it's:
| |||
feedback
|
guys the answer was as simple as this:
| |||
feedback
|