@@Matthias Scharwies
BTW: Würdet ihr const-Variablen in CAPITAL LETTERS schreiben oder wie die MDN in normaler Kleinschreibung?
I.d.R. klein. Weil das, was in JavaScript const
ist, über das hinausgeht, was Konstanten in anderen Sprachen (PHP) sind.
So sind bei mir sämtliche Referenzen auf DOM-Elemente const
:
const detailsElement = document.querySelector('details');
Eigenschaften dieser Objekte sind nicht unbedingt konstant, sondern können geändert werden:
detailsElement.open = true;
Oder wie im jüngsten Mathe-Rätsel:
const calendarium = [29, 30, 31];
Das Array wird danach aber noch erweitert:
for (let monthLength of monthLengthsInYear) {
for (let i = 1; i <= monthLength; i++) {
calendarium.push(i);
}
}
Großschreiben würde ich echte Konstanten wie z.B.
const PHI = (1 + Math.sqrt(5))/2;
Das aber eher ins Math
-Objekt hinein:
Math.SQRT5 = Math.sqrt(5);
Math.PHI = (1 + Math.SQRT5)/2;
😷 LLAP
--
“When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down ‘happy.’ They told me I didn’t understand the assignment, and I told them they didn’t understand life.” —John Lennon
“When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down ‘happy.’ They told me I didn’t understand the assignment, and I told them they didn’t understand life.” —John Lennon