Seeking a method to strip object properties before sending them to the front-end.
Why does this code work as intended:
var obj = {
name: 'cris',
age: 22,
}
console.log(obj) //displays name and age
delete obj.name
console.log(obj) //displays age
while this one does not:
User.findOne({ username: req.query.username }, function (err, user) {
if (user != null) {
console.log(user) //displays all properties
delete user.salt || delete user['salt']
console.log(user) //displays all properties
}
});