TypeScript is a superset of JavaScript, meaning it's a layer around JS with more methods and that makes you follow a certain way of development that you don't have to otherwise in vanilla (like having to set the types of your variables).
🔗 Top JavaScript Trends to Watch in 2021
Object.assign()
const initialState = {
form: {
date: [today, today],
},
list: []
};
const slice = createSlice({
name: key,
initialState,
reducers: {
init: draft => {
// draft.form = initialState.form
// draft.list = initialState.list
Object.assign(draft, initialState);
}
}
});
Object.assign()
으로 한 번에 처리할 수 있다.