<p style="line-height: 18px; font-size: 18px; font-family: times;">
Click "<i>Load samples</i>" to view and edit more JS samples.<br>
<br>
Labyrinth generated with JavaScript:<br><br>
<script>
var n = 100;
var sample = [];
for (var i = 0; i < n; i++)
sample.push({});
console.log(sample.length);
var map = {};
map[5] = 3;
console.log(map.length);
</script>
</p>
Hi all:
I am a New hand in JavaScript and much more familiar to C(C++).
I tested the code above & cannot figure out the meaning of map.
What's the difference if I declare:
A. map = []; B. map = {};
way A seems to be an empty array but B to be an empty object.
Why I can set it as the way of array? (by [] operator such as map[5] = 3).
Why the length of map is undefined?
Could I deem map as a hash table of JavaScript?
Thanks.