Last active
January 27, 2018 16:19
-
-
Save onelharrison/ac5d30620ce06154b3682baf7d2ad0da to your computer and use it in GitHub Desktop.
Code snippet showing the behavior of passing undefined to the moment function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ................................ | |
// behavior in moment.js v2.x.x | |
// ................................ | |
const momentWithUndefinedArg = moment(undefined); | |
const momentWithNoArgs = moment(); | |
// expected result | |
momentWithNoArgs.isValid(); // true | |
momentWithNoArgs.format("YYYY-MM-DD"); // today's date | |
// undexpected result | |
momentWithUndefinedArg.isValid(); // true | |
momentWithUndefinedArg.format("YYYY-MM-DD"); // today's date | |
momentWithUndefinedArg.isSame(momentWithNoArgs); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment