Possible Duplicate:
array join() method without a separator
I'm trying to code a simple array that will then be displayed as a single, continuous line of text with no comma's gaps or separations of any kind. For example, if the array was about fruit, and the fruit involved were apples[0] and bananas[1], it would be displayed as applesbananas.
I am also using socket io and tried the array.join command, but that came up as a 'native expression' in the cmd, which I wasn't sure what to do with.
This is the code I have so far:
var A = 0
var B = 0
var master = new Array();
io.sockets.on("connection", function (socket) {
socket.on("message", function (data) {
var new_data = data.split(',');
if (new_data == 'A') {
master.push(new_data)
console.log(A);
}
else if (new_data == 'B') {
master.push(new_data)
console.log(B);
}
var final = (master.join);
console.log(final);
socket.emit("message", 'master,' + final);
socket.broadcast.emit("message", 'master,' + final);
Right now, this .join expression is being displayed as a native expression in the cmd. Is there any way to join the array elements in a way the cmd or socket io will understand?
Thanks for the help!
.joinis a method, you have to call it: developer.mozilla.org/en-US/docs/JavaScript/Reference/….master.join(",")?