From: Bastian Dehn Date: Fri, 17 Dec 2021 14:57:37 +0000 (+0100) Subject: change: allocation memory outside for loop X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=454caa07cc08e60c42c8b9a8b79af057959720a6;p=calender.git change: allocation memory outside for loop --- diff --git a/cal.js b/cal.js index 51be8b3..b38e9a3 100644 --- a/cal.js +++ b/cal.js @@ -39,13 +39,14 @@ class Month function addMonthDaysHeader() { + let date = new Date(); + let month = null; let monthdaysheader = document.createElement("tr"); monthdaysheader.classList.add("row"); monthdaysheader.classList.add("monthday"); - let date = new Date(); for (let i = 0; i < 12; i++) { - let month = new Month(date.getYear(), i); + month = new Month(date.getYear(), i); month.createDaysHeader(monthdaysheader); } @@ -55,12 +56,13 @@ function addMonthDaysHeader() function addMonthHeader() { let date = new Date(); + let month = null; let header = document.createElement("tr"); header.classList.add("row"); header.classList.add("month"); for (let i = 0; i < 12; i++) { - let month = new Month(date.getYear(), i); + month = new Month(date.getYear(), i); header.appendChild(month.createMonthHeader()); }