why calling split and splice gives empty array?
<p>In this JavaScript, why don't i get <code>azbc</code>?</p>

<pre><code>var x = "a-b-c".split('-').splice(1, 0, 'z');
alert(x.join(''));
</code></pre>

<p><code>split</code> returns an array containing <code>a</code>, <code>b</code> and <code>c</code>.</p>

<p>Shouldn't <code>splice</code> insert <code>z</code> after <code>a</code> and gives me <code>azbc</code>?</p>

<p>Why do i get an empty array?</p>

<p>note:
i know that what i want can be accomplished by:</p>

<pre><code>var x = "a-b-c".split('-')
x.splice(1, 0, 'z');
alert(x.join(''));
</code></pre>

<p>since <code>splice</code> "modifies" the original array itself. shouldn't it modify <code>{a,b,c}</code> to <code>{a,z,b,c}</code> and then be assigned to <code>x</code>?</p>

<p>got it... the code below helped me to understand.</p>

<pre><code>var x = "a-b-c".split('-')
x = x.splice(1, 0, 'z');
alert(x.join(''));
</code></pre>
