Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

TFB(ook) by TFA(uthor) of TFA(rticle) discusses the issues with open recursion, and describes a pattern for using ECMAScript 2015 symbols to address this exact problem:

    const books = Symbol(“books”);

    const BookCollector = {
      addToCollection (name) {
        this.collection().push(name);
        return this;
      },
      collection () {
        return this[books] || (this[books]= []);
      }
    };


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: