use
.call()
instead of.apply()
to invokeunshift()
set
arguments
as thethis
value ofunshift()
set
'hello'
as the argument tounshift()
Array.prototype.unshift.call(arguments, 'hello');
As @lonesomeday pointed out, you can use .apply()
instead of .call()
, but you need to pass an array-like argument as the second argument. So in your case, you'd need to wrap 'hello'
in an Array.