So i have this program, it took me a while to figure out how to create objects dynamically. Based on other stats. Anyhow, i was wondering why this actually works. It makes one object for each td. Eg, Currently it has 100 td elements. I wanted to be able to seperate information for each td and be able to acess it based on the tds id #. of which that works fine.
Why are the objects accessible as just like any other object?
Im kind of puzzled by the part of why it works. I know that it does lol.
Anyhow here is my code... It placed at the end of the html document right before /body.
<script>
(function (){
var list = document.getElementsByTagName("td");
var number = 0;
var text = '';
text += '<script>';
text += 'var plots = {\r';
while (number <= list.length - 1) {
text += number + ' : {\rstamp : 0\r';
if (number >= list.length - 1) {
text += '}}\r';
number++
} else(text += '},\r');
number++
}
text += '</\script>';
document.write(text);
})();
</script>
So again, if you can help me understand, Why is it that these work as if i hard coded the objects in???
Basically, i made a script that makes a script... kinda odd to me.
Btw the \r's are only there to make it more readable when looking ad the source code in the console. no other reason. they are not needed of course.
like to know why 3dgoo removed (function (){ was there and is supposed to be there otherwise it does not work... Thanks.