title: Difference between Javascript object and Typescript object
body: <p>I am trying to figure out if a <code>Typescript</code> object is same as a <code>Javascript</code> object. I have a <code>typescript</code> variable into which I want to typecast result of <code>JSON.parse</code> which I suppose creates a <code>javascript</code> <code>object</code> from a <code>json</code> but I am unable to do it.</p>
  
  <p>I have the following two classes</p>
  
  <pre><code>export class User {
    constructor (public firstname:string,
                 public lastname:string,
                 public email:string,
                 public password:string=""){} 
  }
  
  export class UserProfileAPI {
    'external-profile': User;
    constructor(externalProfile:User){ 
      this['external-profile'] = externalProfile;
    }
  }
  </code></pre>
  
  <p>I have created a spec to test that an <code>object</code> created explicitly is same or similar to object created by <code>json.parse</code> but they don't seem to be.</p>
  
  <pre><code> fit('should test if Typescript object is same as Javascript object',()=&gt;{
      let user = new User('manu','chadha','test@test.com');
      let dummyUserProfile:UserProfileAPI= new UserProfileAPI(user);
      console.log('dummy profile is ',dummyUserProfile);
      let dummyProfile2:UserProfileAPI = JSON.parse('{"external-profile":{"firstname":"manu","lastname":"chadha","email":"test@test.com"}}');
      console.log('dummy profile 2 is ',dummyProfile2);
      console.log('dummy profile1 == dummy profile 2',(dummyUserProfile == dummyProfile2));
      console.log('dummy profile1 === dummy profile 2',(dummyUserProfile == dummyProfile2));
      expect(dummyUserProfile).toEqual(dummyProfile2);
      expect(dummyUserProfile).toBe(dummyProfile2);
    });
  </code></pre>
  
  <p>In the above case, <code>dummyUserProfile</code> is printed as <code>LOG: 'dummy profile is ', UserProfileAPI{external-profile: User{firstname: 'manu', lastname: 'chadha', email: 'test@test.com', password: ''}}</code> but <code>dummyProfile2</code> is printed as <code>LOG: 'dummy profile 2 is ', Object{external-profile: Object{firstname: 'manu', lastname: 'chadha', email: 'test@test.com'}}</code> and both the comparisons return <code>false</code>. Why?</p>