JavaScript terminology: non-function-valued property

Jeff Walden jwalden+es at MIT.EDU
Fri Jul 22 16:28:27 PDT 2011


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|.)

Jeff


More information about the es-discuss mailing list