Wow, I had no idea this would receive so many replies... Even though
most of them are irrelevant to my question.
First some apologies:
I always use \t for indendation in my editor, so I'm sorry for not
following the expected indendation rules as I wasn't aware of them.
Neither was I aware that "self" is an alias for "window". Won't use it
again, clearly it causes too much confusion. For all I care though, I
don't see much use for "self"...
Sorry for omitting the DOCTYPE & title elements. It's only a testpage
and I didn't think it would cause any harm in a browser like FF or
chrome.
Another note: I'm not a javascript expert (as you might have noticed
from the fact I'm not very familiar with the way closures work in
javascript), and I'm not really interested in IE compatibility. At
this point pretty much everything I do consistently breaks in IE,
which is probably not a surprise because I'm using popular HTML5
elements anyway.
To conclude this message, I now think I pretty much understand how
closures work in ecmascript. I still find it pretty unintuitive
though, given the c-like syntax... Reminds me too much of c when it's
in fact quite a different language.
It does not change the object. It does change the contents of the object.
It does change the object... p and o aren't objects, they're
references. By modifying o.j you're changing the object that o
references.
Changing the object and changing the contents of the object is
essentially saying the same thing. What you're not changing are the
values of o and p, which means they still reference the same object.
But the object itself has been modified.
I'm thinking you two are just saying the same thing, but clearly
disagree on the vocabulary...