8-3. 문장을 함수로 옮기기
적용 시점
절차
예시
❌Before
const getNowDateForm = () => {
const date = new Date();
const yyyy = date.getFullYear();
const mm = ("0" + (1 + date.getMonth())).slice(-2);
const dd = ("0" + date.getDate()).slice(-2);
return `${yyyy}-${mm}-${dd}`
}
const createOrderInform = ({ price, uidProduct }) => {
...
const timeString = new Date().ISOString().substr(11, 8)
const nowDate = getNowDateForm();
...
}
const join = (userInfo) => {
...
const timeString = new Date().ISOString().substr(11, 8)
const nowDate = getNowDateForm();
}⭕After
Last updated