var data is return undefined
Here is the code
var data;
    function my_function(newData) {
        console.log(newData)//Everything is okay here, {name: 'Arnel Cariaga', email: 'sadas@sdfs.sad'}
        data = newData;
    }
    socket.on('hello', function(data) {
        var newData = JSON.stringify(data);
        my_function(newData)
    });
    console.log(data) //I get UNDEFINED HERE
 
    