[ JavaScript ] 특정 값으로 배열 채우기
const arr = new Array(4).fill('a') // ['a','a','a','a'] arr.fill("b", 1); // ["a", "b", "b", "b", "b"] arr.fill("c", 2, 4); // ["a", "b", "c", "c", "b"] arr.fill(5.5, -4); // ["a", 5.5, 5.5, 5.5, 5.5] arr.fill(0, -3, -1); // ["a", 5.5, 0, 0, 5.5] 참고한 게시물 https://april.gitbook.io/learning-js/chapter-8./8.2/8.2.6
2024. 1. 16.
[ JavaScript ] Object.freeze
Object.freeze 를 사용하면 좋은 점 ReadOnly여서 해당 값이 보인다. 이게 무슨 말이냐 하면, export const NAV = { ABOUT: 'About', ARCHIVE: 'Archive', SKILLS: 'Skills', PROJECTS: 'Projects', CONTACT: 'Contact', }; export const NAV = Object.freeze({ ABOUT: 'About', ARCHIVE: 'Archive', SKILLS: 'Skills', PROJECTS: 'Projects', CONTACT: 'Contact', });
2023. 11. 27.