title: Why did I have to use `toObject()` in mongoose to find out if an object has a property?
body: <p>It's to my understanding that there is no <code>.toObect()</code> in JavaScript but it is used in mongoose to change the mongoose documents to an object so you can use JavaScript built in functions. </p>
  
  <p>I don't have a grasp on when to use it. sometimes when i get an array of docs I could use forEach on the returned array and then other times I would spend 20 minutes working out why the forEach doesn't work. then I would add <code>.toObject</code> to the returned Array and the forEach would work. something like that. I'm not sure about my memory if it was forEach or something else. </p>
  
  <p>Anyways this is the latest weird issue. I'm in EJS and I needed to do <code>&lt;% console.log("typeof", user.toObject().hasOwnProperty("facebook")) %&gt;</code> to work instead of  <code>&lt;% console.log("typeof", user.hasOwnProperty("facebook")) %&gt;</code> . The one with the <code>.toObject()</code>  consoles :  <code>typeof true</code> the one without consoles <code>typeof false</code> . That seems weird to me. Is user a mongoose document? How could I use .toObject in ejs? Oh wait a minute. Im just thinking is it because it is in the "<code>&lt;%%&gt;</code>" it gets connected to the server side code and maybe I have mongoose required in my <code>server.js</code>  <strong>Why did I have to use toObject to get the <code>true</code> value</strong>?</p>
  
  <p>any ways I didn't think I needed to use <code>.toObject()</code></p>
  
  <p>This is what I have in my .js file : <code>res.render("editProfile", {aboutUser : returnedUser, user : req.user});</code> I think <code>req.user</code> is from passport not mongoose. </p>
  
  <p>user obj</p>
  
  <p><code>{ _id: 581a2chan3changed727, defaultImage: 'https://scontefrfrxxffbcdn.net/v/t1.0-1/s148x148/29731_575634691740_1085883_n.jpg?oh=797bc81addf3611309changedoe=588AC839', urlname: 'Jacchanged', momented: 'Nov 2, 2016', username: 'Jack Schuldenfrei', __v: 0, usefulness: [], createdOn: Wed Nov 02 2016 14:15:47 GMT-0400 (Eastern Daylight Time), shortId: 'rkn8powgl', pointsRecord: [], repPoints: 0, facebook: { posts: '{"email":"jschuldenfreiGTGTGTgchanged,"name":"Jack Schuchange","gender":"male","picture":{"data":{"height":148,"is_silhouette":false,"url":"https:\\/\\frfr.net\\/v\\/t1.0-1\\/s148x148\\/29731_575634691740_1fr5883_n.jpg?oh=797bc81addf36113e0933a67eef32ab9&amp;oe=588AC839","width":93}},"id":"10100584555845400"}', gender: 'male', email: 'jschuldenfredu', name: 'Jack changes', token: 'EAAPs693O1UMBAHwTcyZAPtRiXrwvxrBWhGCJZCQlAIfHRZAiCLY3tYDVoviB4yDrK68WrsUnuxlcHfUJE984aAvWOnFZASqbUjYZAhHnsL0mFCZCNRQwsn3oJn1acu1qnSPFko6I3ShZAtPIMumrVlpVxR0ZD', id: '1010058386584400' }, reviews: [] } { _id: 581a2d53380e4c70ac728, userId: 581a2d380e4c7037aac727, username: 'Jack changed', urlname: 'Jachanged', __v: 0, question1: { name: 'This is for question1' } }</code></p>
  
  <p>I get that user object by doing <code>&lt;%=user%&gt;</code> in the ejs file.</p>