Skip to content

Comment on Xto6 modernizes your JavaScript code

Comments

Wow, the example is atrocious,

  Person.prototype.getAge = function (birthYear) {
    var age = 2015;
    age -= birthYear;

    return result;
    // Do you mean return age?
  };

  Object.defineProperty(Person.prototype, 'age', {
    get: function () {
      return this.getAge();
      // getAge function takes a required parameter.
    }
  });
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.