I have an array declared in server.js in a Node.js application. I want the client side to be able to access the array and it's content. Is that possible? If yes, how can I do that? I tried the following but the console always says global array not defined
server.js
//connection code above this
var global_array=[];
socket.on('change', function(data){
socket.broadcast.emit('change', data);
global_array.push(data);
console.log(global_array);
});
.... //rest code
main.js
if (typeof global_array !== 'undefined' && global_array.length > 0) {
console.log(global_array);
} else {
console.log("global array not defined");
}