{"action":"created","issue":{"url":"https://api.github.com/repos/moment/moment/issues/3080","repository_url":"https://api.github.com/repos/moment/moment","labels_url":"https://api.github.com/repos/moment/moment/issues/3080/labels{/name}","comments_url":"https://api.github.com/repos/moment/moment/issues/3080/comments","events_url":"https://api.github.com/repos/moment/moment/issues/3080/events","html_url":"https://github.com/moment/moment/issues/3080","id":144912951,"number":3080,"title":"Formatting a moment object breaks equality comparisons","user":{"login":"xiphiaz","id":721513,"avatar_url":"https://avatars.githubusercontent.com/u/721513?v=3","gravatar_id":"","url":"https://api.github.com/users/xiphiaz","html_url":"https://github.com/xiphiaz","followers_url":"https://api.github.com/users/xiphiaz/followers","following_url":"https://api.github.com/users/xiphiaz/following{/other_user}","gists_url":"https://api.github.com/users/xiphiaz/gists{/gist_id}","starred_url":"https://api.github.com/users/xiphiaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiphiaz/subscriptions","organizations_url":"https://api.github.com/users/xiphiaz/orgs","repos_url":"https://api.github.com/users/xiphiaz/repos","events_url":"https://api.github.com/users/xiphiaz/events{/privacy}","received_events_url":"https://api.github.com/users/xiphiaz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-31T14:09:52Z","updated_at":"2016-03-31T15:53:00Z","closed_at":null,"body":"When a moment object is formatted, the equality of the object with a clone of the unformatted object becomes false. This is unexpected, as formatting operations should be nullipotent (not change the underlying object).\r\n\r\nSmall example:\r\n\r\n```\r\nfoo = moment();\r\nbar = foo.clone();\r\n_.isEqual(foo, bar); //true\r\nangular.equals(foo, bar); //true\r\nfoo.format();\r\n_.isEqual(foo, bar); //false\r\nangular.equals(foo, bar); //false\r\n```\r\n\r\nSee https://jsfiddle.net/x4hr9qmq/1/for fiddle\r\n\r\nNote that `===` will always fail, but this is expected as `moment.clone()` should return a different object, but equality comparitors like lodash's `_.isEqual` and angular `angular.equals` should return true as they compare properties not object identity.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/moment/moment/issues/comments/203996777","html_url":"https://github.com/moment/moment/issues/3080#issuecomment-203996777","issue_url":"https://api.github.com/repos/moment/moment/issues/3080","id":203996777,"user":{"login":"xiphiaz","id":721513,"avatar_url":"https://avatars.githubusercontent.com/u/721513?v=3","gravatar_id":"","url":"https://api.github.com/users/xiphiaz","html_url":"https://github.com/xiphiaz","followers_url":"https://api.github.com/users/xiphiaz/followers","following_url":"https://api.github.com/users/xiphiaz/following{/other_user}","gists_url":"https://api.github.com/users/xiphiaz/gists{/gist_id}","starred_url":"https://api.github.com/users/xiphiaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiphiaz/subscriptions","organizations_url":"https://api.github.com/users/xiphiaz/orgs","repos_url":"https://api.github.com/users/xiphiaz/repos","events_url":"https://api.github.com/users/xiphiaz/events{/privacy}","received_events_url":"https://api.github.com/users/xiphiaz/received_events","type":"User","site_admin":false},"created_at":"2016-03-31T15:52:59Z","updated_at":"2016-03-31T15:52:59Z","body":"@maggiepint yea I understand there are lots of internal properties, and that the deep checking is probably not performant, but for the needs I have, performance is nearly irrelevant as it is a on-save event, so very infrequent and client-side.\r\n\r\nI think a better solution would be to store the internal moment properties as non-enumerable, as both lodash `_.isEqual` and angular `.equals` both only check enumerable properties. "}}