Non-method functions and this

Sam Tobin-Hochstadt samth at ccs.neu.edu
Mon May 16 07:20:38 PDT 2011


On Mon, May 16, 2011 at 10:15 AM, David Herman <dherman at mozilla.com> wrote:
>
> d) At runtime, a function invoked as a non-method gets a dynamic ReferenceError if it tries to refer to |this|. This would just be kind of obnoxious, I think, since if the function wants to test whether it's been called as a non-method it has to do something like
>
>    let nonMethod = false;
>    try { eval("this") } catch (e) { nonMethod = true }
>

There's also more-obnoxious (e), where any function that includes a
reference to |this| produces a ReferenceError immediately when
invoked, instead of when (or if) it refers to |this|.  That's what I
thought Axel was suggesting.
-- 
sam th
samth at ccs.neu.edu


More information about the es-discuss mailing list