Arvind said:
I am not sure i understood your argument, mypoint was about the
reference to types.
JavaScript has no types. We weren't talking about types, anyway. We
were talking about classes, which JavaScript (some versions) also
doesn't have, nor does it have anything like them. You are attributing
too much meaning to "new dog(...)".
Now this 'dog' type can definitely be passed around
and used like any other object....
JavaScript DOES have objects. That doesn't mean it has classes or
types.
There is do 'dog' type. The only thing called 'dog' here is a function,
which happens to have been used as a constructor to create an object.
The interpreter doesn't possess any knowledge about that object just by
virtue of its having been created by using the 'dog' function as a
constructor. I could just as easily write:
var herdog = new Object();
herdog.name = 'Buddy';
herdog.age = 1;
Now this new variable 'herdog' can be used in exactly the same places
and contexts as the variables 'mydog' and 'yourdog'. If I then wanted
to pass 'herdog' to the airline reservation subsystem, I could write:
herdog.carrier = 'United';
herdog.flightNum = '1234';
herdog.departure = new Date();
reserveSeat(herdog, 'Prefer Window Seat');
That's what it means to not have types or classes. 'herdog' does not
necessarily have anything in common with any object that was created
with any particular constructor.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation