Get + Set
Day.js는 오버로딩된 getter와 setter를 사용합니다. 인자 없이 호출하면 getter로, 인자와 함께 호출하면 setter로 작동합니다.
Day.js 객체는 불변 객체이므로, setter는 항상 새로운 Day.js 인스턴스를 반환합니다.
이는 네이티브 Date 객체의 해당 메서드와 동일한 동작 방식입니다.
js
dayjs().second(30).valueOf(); // => new Date().setSeconds(30)
dayjs().second(); // => new Date().getSeconds()UTC 모드에서는 UTC에 해당하는 메서드에 매핑됩니다.
js
dayjs.utc().second(30).valueOf(); // => new Date().setUTCSeconds(30)
dayjs.utc().second(); // => new Date().getUTCSeconds()