본문 바로가기
728x90
반응형
SMALL

programming375

chapter 9) combination of array and object ### Key Points of the Script - **Students Array**: An empty array `students` is initialized to store the student objects. - **Populating the Array**: The `push` method is used to add objects to the `students` array. Each object represents a student and includes their name and scores in four subjects. - **Displaying Data**: `JSON.stringify(students, null, 2)` is called to convert the `students` a.. 2025. 1. 2.
chapter 9) Override ### Basic Class and Method Invocation - **Class `Lifecycle`**: Defines a simple class with a `call` method that invokes three other methods (`a`, `b`, and `c`) in sequence. Each of these methods logs a message to the console when called. - The instantiation and immediate invocation of `call` on a `Lifecycle` object result in the sequential logging of `"a() method call"`, `"b() method call"`, and.. 2025. 1. 1.
chapter 9) declair class and new instance ### Overview of the `Student` Class - **Constructor**: The `Student` class defines a constructor that initializes a new instance with the student's name and their scores in Korean (`kor`), English (`eng`), Math (`math`), and Science (`sci`). ### Creating and Storing `Student` Instances - An array named `students` is created to store instances of `Student`. - The `push` method is used to add new .. 2024. 12. 31.
chapter 9) toString() method override ### Key Elements of the `Pet` Class - **Constructor**: Defines the `Pet` class with a constructor accepting `name` and `age` parameters, which are assigned to the instance. - **`toString` Method**: Provides a custom string representation for instances of the `Pet` class. When a `Pet` instance is converted to a string (explicitly or implicitly), this method returns a string containing the pet's n.. 2024. 12. 30.
728x90
반응형
LIST