15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

488<br />

array.concat()<br />

<strong>JavaScript</strong> <strong>Examples</strong> <strong>Bible</strong>: The Essential Companion to <strong>JavaScript</strong> <strong>Bible</strong><br />

✦ Walk through the steps for the array.splice() method to observe how<br />

<strong>JavaScript</strong> in NN4+ and IE5.5+ can replace entries inside an array. One example<br />

replaces three items with one, indicating that you are not bound to maintaining<br />

the same array length.<br />

Array Object Methods<br />

array.concat(array2)<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓ ✓ ✓ ✓ ✓<br />

Example<br />

Listing 37-6 is a bit complex, but it demonstrates both how arrays can be joined<br />

with the array.concat() method and how values and objects in the source arrays<br />

do or do not propagate based on their data type. The page is shown in Figure 17-1.<br />

Figure 17-1: Object references remain “alive” in a concatenated array.<br />

After you load the page, you see readouts of three arrays. The first array consists<br />

of all string values; the second array has two string values and a reference to a form

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!