如果变量 value 是全局变量,为什么当我 console.log()从socket.on('Led_1')中退出时却未定义? `
var io = require('socket.io-client');
var value;
var socket = io.connect('http://105.155.150.85/');
socket.on('Led_1',function(data){
value = data.message;
console.log(value); // Here it shows the value.
});
console.log(value); // here it shows undefined.
`