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

Maybe my comment was misleading - the important part is the property read, not the `console.log`. The following code might be an infinite loop in JavaScript:

  function adder(arr, obj) {
    for (var i = 0; i < arr.length; ++i) {
      obj.x += i;
    }
  }

  var arr = [1];
  var obj = Object.defineProperties({}, {
    x: {
      get: function() { return 1; },
      set: function(v) { arr.push(v); }
    }
  };
  adder(arr, obj);


V8 can inline getters and setters like it can inline normal functios.




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

Search: