Exactly. You can omit the `a1.length' argument, though.
Looks good Johannes. Thanks for directly addressing the question.
Now that the proverbial cat is out of the bag: there is an
example very > similar to the test case posted by VK at
<
https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global...>
Had the OP read the Reference (included in "RTFM") as (I) recommended,
and referred to by the FAQ, instead of waiting for someone to post the
spoon-fed answer, they would have had the answer several hours earlier.
Another botched presumption about me. It would be so refreshing
to see posts from you that are insult free, address issues head on,
and
are free of presumption about me. I was pleased to read your answer
and
had thought you'd turned over a new leaf at:
http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/5cfe80871d53b921/
since you had a specific solution to an asked question. I rather hope
it will become less of an anomaly.
But excuse me - Recommended? In your first 6(!) posts to this topic,
not one of which indicated that you had a competitive answer, the
only time I see a mention of reading a reference is in the 6th one.
But even had you referenced a manual in a halfway timely fashion,
without detracting from your message by encasing it in insult, it
would
not have been effective, because this phrase has in general become
almost a
joke as far as being helpful. In some cases, it's more of an
indication
that the person doesn't know the answer. It's about as useful as
saying,
"Read the relevant material, and you'll find an answer", or "Search on
google, someone's sure to have covered this in the past". Possibly
true, just not usually particularly helpful.
If a person wants to be helpful along these lines, then I
would suggest that it's far more effective to say, use these
search terms on Google: xxx yyy or If you look at the
following site it should address your question.
In any case, the OP (that would be me), already had an answer several
hours before posting. I did not post the question for my benefit; it
was rather meant as an excercise with an interesting point.
Johannes gave a nice answer. In my routine, where I do not need
to have a return value (yes, I realize it alters the problem)
since I can reuse the input array, I used:
function insertArray(a1, a2, pos) {
a1.splice.apply(aImg, [pos, 0].concat(a2)); }
which approach, by the way, I don't see directly mentioned
in the manual page you referenced.