This method will check if the moment is same as another moment. It returns true or false.
moment().isSame(Moment|String|Number|Date|Array); moment().isSame(Moment|String|Number|Date|Array, String);
var issame = moment([2015, 10, 01]).isSame([2015, 10, 01]);
Note that as with isBefore, we can use unit with isSame() method. Following are the units supported: year, month, week, day, hour, minute and second.
var issame = moment([2015, 10, 01]).isSame([2015, 05, 10], 'year');
Since the year of both moments is matching, it gives true as the output.
var issame = moment([2015, 10, 01]).isSame([2015, 05, 10], 'month');
Note that in the above example the month is not matching, so it gives the output as false.
You will get false for month unit even if the year is not matching. Observe the following code for the same.
var issame = moment([2015, 10, 01]).isSame([2014, 05, 10], 'month');
var issame = moment([2015, 10, 01]).isSame([2015, 05, 10], 'day');