[thelist] JavaScript array problem

Fernando J. Gomez fgomez at criba.edu.ar
Fri Aug 8 17:12:30 CDT 2003


Hi Simon,

> In javascript, Objects are handled by reference.

OK, that's what I was suspecting, and no one had told me!  ;-)

> array1 = array2;
> Remove that line and everything should work fine.

Everything? Oh, well... that's why my previous posting included a brief
explanation of what I was trying to accomplish in my application. I want to
keep a backup copy of my initial array, in case the user cancels the
operation and all his modifications must be discarded. I must note that,
contrary to my trivial example, these arrays are not necessarily *empty*
when the script is called. So, how am I supposed to keep a copy of the data
stored in an array, without getting these unwanted coupling?

Or maybe there's a simpler approach that I can't see?

> Incidentally, I recently bought the O'Reilly book "Javascript: The
> Definitive Guide" and it has superb coverage of the core Javascript
> language covering 11 chapters, which includes detailed coverage of
> this issue.

Thanks for the recommendation. Sadly, buying computer books in this country
is not so easy as it used to be (they cost 3 times more since last year!).

Thanks for your quick answer :)

Fernando


=======================================================
Fernando J. Gómez

Biblioteca Dr. Antonio Monteiro
Instituto de Matemática de Bahía Blanca (CONICET/UNS)
Av. Alem 1253
8000 Bahía Blanca - Argentina
=======================================================




More information about the thelist mailing list