javascript 中的 init 函数有问题,在 init 函数中分配后使用属性

Having problems with init function in javascript and using the properties after assigning in init function

我正在写三个 classes 并想显示一些东西,最后一个 class 使用 init 函数为其属性赋值,见下文。但是它并没有像我预期的那样工作。

class Circle1 {
    constructor(options) {

  }

  render() {
    document.getElementById('result').innerHTML = 'Hello, ';
  }
}

class Circle2 {
    constructor(options) {

  }

  render() {
    document.getElementById('result').innerHTML += 'My';
  }
}

class Circle {
    constuctor(options) {
        this.x = options.x;
        this.y = options.y;
        this.length = options.length;

        this.bodies = [];
        this.init(options);
    }

    init(options) {
        this.first = new Circle1(options);
        for (let i = 0; i < this.length; i++) {
            this.bodies.push(new Circle2(options));
        }
    }

    render() {
    /**
    this.first.render();

    this.bodies.forEach(function(body) {
        body.render();
    });
    **/
        document.getElementById('result').innerHTML += 'World';

    }
}

var c = new Circle({
    x: 20,
    y: 20,
    length: 6
});

c.render();

此代码将在屏幕上显示 "World"。

但是,如果我取消对注释代码的注释,并尝试在屏幕上显示 "Hello, My (times length) World" 但它什么也没有显示。

我对 class 中的 init 函数很困惑。我以为我可以为该函数中的属性赋值,但结果告诉我它不起作用。我的代码有什么问题?

这里是jsfiddlelink.

constructor 的名称有误(未调用构造函数):

class Circle {
    constuctor(options) {

==>

class Circle {
    constructor(options) {

[https://jsfiddle.net/5sv5hwLb/]