Maximum call stack size exceededet

There’s a conflict between the set skill function name, and the this.skill property.

  set skill(value) {
    this.skill = value;
  }

Give the set skill function a capital first letter, and that will resolve the circular reference.

Hi @Growly, well a setter function is getting invoked by just setting the property of that name, which you’re doing inside the setter – hence the infinite recursion. If you need a value property under the hood, a common convention would be to prefix it with an underscore:

class Foo {
  get skill () {
    return this._skill
  }

  set skill (value) {
    this._skill = value
  }
}
2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.