728x90 300x250 2024/051 합성(Composition) 합성은 다른 객체를 포함하여 기능을 확장하는 방법을 말한다. 필요한 기능을 구현하고 있는 객체와 합성해서 기능을 사용하는 것을 말하며 기능을 구현하고 있는 객체와 사용하는 객체 간의 관계를 합성관계라고 한다. // Engine 클래스 정의class Engine { constructor(horsepower) { this.horsepower = horsepower; } start() { console.log("Engine started."); }}// Car 클래스 정의class Car { constructor(make, model, engine) { this.make = make; this.model = model; this.engine = engine; } star.. 2024. 5. 2. 이전 1 다음 728x90 반응형