There are no such conflicts between JavaScript references. You are just trying to dereference
undefined
object. This is a special object specific to JavaScript, distinct from
null
and all other values. It is used by the runtime system when you declare some variable but don't initialize it. Also, you can assign
undefined
to any other object at any time.
Consider this:
var Cookie;
Cookie = undefined;
function A() { alert("Do something"); }
Cookie = A();
var someOtherVariable = Cookie;
var someOtherVariable = Cookie.a;
I tried it on Mozilla and Chrome, it actually throws
TypeError
with this error message, but I can imagine that some other browser throws different exception object. Reference errors come in different situations, when some variable (
f
in my example below) is not even declared:
var someOtherVariable = f;
On
undefined
object (
primitive value), please see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined[
^],
not to be confused with
null
:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null[
^].
Remaining exception you described is "not a function". Consider this example:
var Element = { };
Element.extend = 42;
Element.extend();
Element.somethingNotCreated();
I hope the exception message is self-explained.
Please don't ask me what your code did wrong; I don't know and, frankly, don't want to know. You just need to understand the first principles, than you can dig it out.
—SA