Flyweight Pattern
Flyweight 패턴은 비슷한 객체를 대량으로 생성할 때 메모리를 보존하는 데 유용한 방법입니다. class Book { constructor(title, author, isbn) { this.title = title; this.author = author; this.isbn = isbn; }}const books = new Map(); // 중복된 책은 제외됨const bookList = []; // 중복된 책 포함 - 즉, 복사본이 있음.const addBook = (title, author, isbn, availability, sales) => { const book = { ...createBook(title, author, isbn), sales, avail..
2024. 12. 8.