title: How to remove __proto__ property from a JSON object?
body: <p>I have the following function based on Node-Express: </p>
  
  <pre><code>//function on server side
  app.get('/loginCheck', loggedCheck, function(req, res) {
      var data = {local: {}, facebook: {}};
      data.id = req.user._id;
      data.local.email = req.user.local.email;
      data.local.fname = req.user.local.fname;
      data.local.lname = req.user.local.lname ;
      data.local.college = req.user.local.college ;
      data.local.degree = req.user.local.degree ;
      data.year = req.user.year ;
      data.mobile = req.user.mobile ;
      data.city = req.user.city ;
      data.facebook.id = req.user.facebook.id ;
      //res.json(data);        
  
      var x = {};
      x.name = "someName"
  
      res.json(x);
  })
  </code></pre>
  
  <p>Following is the code on client side which makes an ajax requests:</p>
  
  <pre><code>//function on client side making an ajax request
  $.get("/loginCheck",function(data,status){
      console.log(data);
  });
  </code></pre>
  
  <p>In the former code on server side, <code>req.user</code> is a mongodb object created by mongoose. What I want to do is send the data object (which has some selected attributes of <code>req.user</code> object) and send the object as JSON as response.</p>
  
  <p>The variable <code>x</code> is a custom created variable.</p>
  
  <p>The problem is: 
  When I send the <code>data</code> object to client, <code>__proto__</code> attribute is also added with the object which is not happening when I am sending <code>x</code> to the client.
  But, I don't want the <code>__proto__</code> in the client side, because, from some articles, I found that there are security issues with <code>__proto__</code>.</p>
  
  <p>I need help on how to remove <code>__proto__</code> from the <code>data</code> object.</p>