How do I work around mutability in moment.js?
问题 I've run into a problem where I have to store the initial values of a moment object but I'm having some trouble preventing my variable from changing along with the original object. Unfortunately Object.freeze() doesn't work, because moment.js returns an "Invalid date" error when I try to format that. 回答1: There's a Moment.js plugin on NPM called frozen-moment - You could use moment().freeze() in place of Object.freeze(moment()) . Otherwise, vanilla Moment.js has a clone method that should