The result for .join is different from .push or .pop.
var mack=[];
mack.push("dog", "cat");
mack.join(" ");
alert(mack);
Console.log: ["dog", "cat"]
var mack=[];
mack.push("dog", "cat");
alert(mack.join(" "));
Console.log: "dog cat"
In the first one,
mack.join(" "); does not change the original mack array, unlike mack.push("dog", "cat"); or mack.pop();.
I'm curious that why this happened. And is there any other method like this?
Pushandpopmethods are used onArrayobject to add or remove data to/from Array and therefore change Array itself.Joinmethod doesn't changeArray, it returnsString- new object, Array remains unchanged as it is. It could be used e.g. for concatenating Strings which are put in array with particular character.More about arrays could be found here: http://www.w3schools.com/js/js_array_methods.asp