var x = 'outside';
function y() {
var x = 'inside';
var code = "if(typeof x === 'undefined'){\
console.log('no x');\
}else{\
console.log(x);\
}";
return (new Function('data', code));
}
var fn = y();
console.log(fn.toString());
fn();
-----------------------------------------------------
瀏覽器 => x = "outside"
node.js => undefined