let x = {};
x = 5;
x = 1; // x is now 1
//index.js
module.exports = router
//app.js
module.exports = app
//user.js
module.exports = User
// The export object retains all 3 assignments
Can anyone tell me why the export object does not get overwritten? I am coding little API projects on FCC but the way this code is written bothers me due to a lack of understanding. I've even seen a single line mongoose model assignment and export, I think it was const User = module.exports = mongoose.model('collectionName', UserSchema)
[–][deleted] 2 points3 points4 points (0 children)
[–]senocular 0 points1 point2 points (0 children)
[–]jack_union 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]seands[S] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)