Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_objects thread: Re: Arrays and Lists


Message #1 by "Volker Schröder" <volker.schroeder@t...> on Tue, 12 Nov 2002 09:32:21
There are no built-in functions like "car" but there are some handy 
methods.
However Javascript objects in general are extendable. You can add 
methods to
JS objects.

Take a look here:
http://developer.netscape.com/docs/manuals/js/core/jsguide15/contents.ht
ml

good luck
bob jones

-----Original Message-----
From: Volker Schr=F6der [mailto:volker.schroeder@t...]
Sent: Tuesday, November 12, 2002 3:32 AM
To: JavaScript Objects
Subject: [javascript_objects] Re: Arrays and Lists


> What I would like to know is if there is anything in Javascript like 
a
> list ala Lisp?  And with it, the functionality of first (car), or 
rest
> (cdr) - again ala lisp.  If this is not so is there any way to
explicitly
...
> The next question is if anyone has tried doing this before, by 
extending
> the Array interface (is one way I was thinking), or any other way and 
if
> they have any tips or possibly libraries they would be willing to
share. 

It looks to me, that most of the functionality your want to use is 
already
available, esp. the shift() method corresponds quite well with the 
car/cdr
operators, so take a look at:
http://msdn.microsoft.com/library/default.asp?url=3D/library/en-
us/script56/html/js56jsmthslicearray.asp
http://msdn.microsoft.com/library/default.asp?url=3D/library/en-
us/script56/html/js56jsmthshift.asp

And if this isn't sufficient, you can extend the Array interface using 
the
prototype property:
http://msdn.microsoft.com/library/default.asp?url=3D/library/en-
us/script56/html/js56jsproprototype.asp

  Return to Index