JSブリッジモード
409 ワード
class Color{
constructor(name){
this.name = name
}
}
class Shape{
constructor(name,color){
this.name = name
this.color = color
}
draw(){
console.log(`${this.name} --- ${this.color.name}`)
}
}
let red = new Color('red')
let yellow = new Color('yellow')
let circle = new Shape('circle',red)
circle.draw()