728x90 반응형 SMALL 개념249 chapter 9) Static keyword ### Key Concepts Illustrated - **Private Field `#length`**: Utilizes a private field to encapsulate the side length of a square, preventing direct access from outside the class. - **Static Property `#counter`**: A private static property tracks the total number of `Square` instances created. This is a private field and is accessed through a public static getter. - **Static Getter for `counter`**.. 2024. 12. 29. chapter 9) use to array ### Direct Calculation in a Loop Initially, the code calculates the sum and average of each student's scores directly within a `for...of` loop. This straightforward approach directly accesses properties of each student object, performs arithmetic operations, and appends the results to a string `output`, which is then logged to the console. ### Using Object Processing Functions The next section i.. 2024. 12. 28. chapter 9) combination get keyword and set keyword ### Overview of the `Square` Class - **Private Field `#length`**: The `Square` class defines a private field `#length`, which is not directly accessible from outside the class. This encapsulation ensures that the length of the square can only be modified in controlled ways, specifically through the class's setter method. - **Constructor**: The constructor takes an initial length for the square a.. 2024. 12. 27. chapter 8) Except ### Approach 1: Failing Silently The first event listener tries to find an `` element using `document.querySelector('h1')` and immediately attempts to set its `textContent` to 'hello'. Since there is no `` element in the document, this attempt results in a TypeError because `h1` is `null` and you cannot set properties on `null`. ### Approach 2: Handling Absence with a Conditional Check The secon.. 2024. 12. 26. 이전 1 ··· 6 7 8 9 10 11 12 ··· 63 다음 728x90 반응형 LIST