The problem of variable exposure in node

first a.js:

var x;
exports.x = x;
console.log (x) / / 123

second b.js:

var a = require (". / a.js");
setTimeout (function () {console.log (a.x)}, 1000);

run b.js and output undefined,. Why? Haven"t you already been exposed?

Jun.16,2021

where does a.js assign a value to x? Please post the complete code


you didn't assign a value to x. Why is there 123? Is there any other place to introduce
?

put aside the above two questions, then mine is right.

clipboard.png


a.js does not assign x, and consolo.log (x) should be undefined

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37ab5-2c094.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37ab5-2c094.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?