js在当前时间后或前添加或减少几个月
function addMonth(date, offset) { if (date instanceof Date && !isNaN(offset)) { let givenMonth = date.getMonth(); let newMonth = givenMonth + offset; date.setMonth(newMonth); return date; } throw Error('argument type error'); }
function addMonth(date, offset) { if (date instanceof Date && !isNaN(offset)) { let givenMonth = date.getMonth(); let newMonth = givenMonth + offset; date.setMonth(newMonth); return date; } throw Error('argument type error'); }