phpjs
Version:
45 lines (37 loc) • 1.05 kB
HTML
<!-- Generated by Rakefile:build -->
<strong>
<a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a>
</strong>
on 2010-06-19 16:04:03 <br />
@ jmweb: Thanks, fixed: https://github.com/kvz/phpjs/commit/fc87874f1823862ae2e4b006f9b4316401c65f33
<hr />
<strong>
jmweb
</strong>
on 2010-05-26 12:33:31 <br />
Note that the array_unshift() implementation given here prepends the array arguments in the wrong order.
As an example:
<pre><code>
var names=['van', 'Zonneveld'];
array_unshift(names,'Kevin','Tim')
// returns 4
//names is now ['Tim','Kevin','van', 'Zonneveld']
</code></pre>
The function should be altered to:
<pre><code>
function array_unshift(/* assumes at least 1 argument passed - the array */){
var i=arguments.length;
while(--i!==0){
arguments[0].unshift(arguments[i]);
}
return arguments[0].length;
}
</code></pre>
As an example:
<pre><code>
var names=['van', 'Zonneveld'];
array_unshift(names,'Kevin','Tim')
// returns 4
//names is now ['Kevin','Tim','van', 'Zonneveld']
</code></pre>
<hr />