I am using NodeJS to create a server that brings in serial data. The serial data is successfully showing in the HTML; however, I would like to create a 'var' that can hold the data. Please can someone help?

// open a connection to the serial server:
var socket = io.connect('http://localhost:8080');

// when you get a serialdata event, do this:
socket.on('serialEvent', function (data) {
// look for the textDisplay element in the HTML below:
var element = document.getElementById('IDTag');
// set the stuff inside the element's HTML tags to
// whatever the 'value' property of the received data is:
element.innerHTML = data.value;

// open the serial port. Change the name to the name of your port, just like in Processing and Arduino:
var myPort = new SerialPort("/dev/tty.usbmodemfa131", {
// look for return and newline at the end of each data packet:
parser: serialport.parsers.readline("\r\n")
});

// listen for new socket.io connections:
io.sockets.on('connection', function (socket) {
// if there's a socket client, listen for new serial data:
myPort.on('data', function (data) {
// set the value property of scores to the serial string:
serialData.value = data;
// for debugging, you should see this in Terminal:
console.log(data);
// send a serial event to the web client with the data:
socket.emit('serialEvent', serialData);
});
});