function test()
{
alert(Array.join.call(arguments,'/')) //alerts /
alert(Array.prototype.join.call(arguments,'/')) //alerts Js/JScript
alert(Array.join(arguments,'/')) //alerts Js/JScript
}
test('Js','JScript');
Why is this difference? Why is it needed to reference prototype first ?
Also why does just Array.join gives required result even when join expects just a separator argument.
Array.joinis a global function. When using call, what you pass as a first argument is thethisobject inside the body of thejoinfunction, then the arguments for thejoinfunction.Array.prototype.joinis for instances ofArray. Therefore, it expectsthisto be the actual array, which is why your second example works. Your second example amounts to callingArray.prototype.joinwith thethisobject beingarguments, which is exactlyarguments.join("/"). See MDN for an explanation.