JavaScript terminology: non-function-valued property

Allen Wirfs-Brock allen at
Fri Jul 22 19:06:58 PDT 2011

On Jul 22, 2011, at 4:28 PM, Jeff Walden wrote:

> On 07/22/2011 04:13 PM, Axel Rauschmayer wrote:
>> In strict-mode, "this" isn’t boxed in, say, String.prototype.* methods. But I don’t know how/whether that reflects the spec.
> This is not quite precisely true.  See the second algorithm in 8.7 GetValue(V).  If you implement exactly the steps in the spec, the boxing occurs whenever you look up a property on a primitive (step 1 of that algorithm) -- be that a data property whose value is a method, a data property whose value isn't a method, or an accessor property.  It happens, however, that that boxed object itself is never directly exposed to code in the program being executed.  So it's possible for an implementation to never actually box |this| in step 1, so long as it appears to behave as if it did.
> Note that if you have an accessor property looked up this way, the |this| seen, if |this| is boxed because the accessor is a function whose code is non-strict, is not *by the exact spec algorithm* the same as the object created in step 1 in the spec.  But again, because the object in step 1 is never exposed, an implementation might box up only one object for both uses.  (Or none, even, if it can get away with such an optimization -- say, because the accessor function never evaluates |this|.)

There is a way to detect that a different object is used in the private value [[Ge]] algorithm of 8.7.1.


Object.defineProperty(Number.prototype, "checkSameThis",  {configurable: true,
      get: function () {
         "use strict";
         this.accessorThis = this;
         return function () {return this.hasOwnProperty("accessorThis ") && this.accessorThis ===this};
alert(1.0.checkSameThis());      //should be false according to ES5 spec.

then try 

alert(new Number(1.0).checkSameThis());     //should be true according to ES5 spec.


More information about the es-discuss mailing list