Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #29072

Re: Scope of "this" variable

Path csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Teemu Likonen <tlikonen@iki.fi>
Newsgroups comp.lang.javascript
Subject Re: Scope of "this" variable
Date Wed, 30 Dec 2015 10:57:20 +0200
Organization A noiseless patient Spider
Lines 49
Message-ID <8737ukgvpr.fsf@mithlond.arda> (permalink)
References <87ziwtqc9t.fsf@mithlond.arda> <87k2nx7zjg.fsf@bsb.me.uk>
Mime-Version 1.0
Content-Type multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature"
Injection-Info mx02.eternal-september.org; posting-host="acd0cf975b2d795ec1eea69942f310f4"; logging-data="12753"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX181NldaatFzKTmitnFUos/QTZE8m40XHic="
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.5.50 (gnu/linux)
Cancel-Lock sha1:czEFDuX8y/FhAkCQ+Cs4h4dtetk= sha1:3V6uvIF4k2Ss2f0oFo4uWgXUmQs=
Xref csiph.com comp.lang.javascript:29072

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Ben Bacarisse [2015-12-29 20:47:15Z] wrote:

> ["this"] is a keyword and not the name of a variable and does not have
> scope. But the object to which the keywords refers does changes as
> execution contexts are created, entered and exited. As such it feels a
> bit like something with scope, but trying to fit it into the model of
> a scoped name will just cause confusion.

> When you call a method like item1.foo.fn2, part of the process
> establishes a value for 'this'.  Calling x.f(...) executes f in a
> context in which this refers to x.  Here, 'this' will refer to
> item1.foo.  I think you'll agree that you want that behaviour more often
> than not.

Thank you, and everybody. Many good details were given. I come mostly
From Common Lisp (I'm still "there") and even the semantics of this
dot.notation.thing is quite new to me, even though its very common. But
I got a fair step forward with this discussion and by reading the
standard. Thanks.

-- 
/// Teemu Likonen   - .-..   <https://github.com/tlikonen> //
// PGP: 4E10 55DC 84E9 DFF6 13D7 8557 719D 69D3 2453 9450 ///

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Scope of "this" variable Teemu Likonen <tlikonen@iki.fi> - 2015-12-29 21:34 +0200
  Re: Scope of "this" variable Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-29 20:47 +0000
    Re: Scope of "this" variable Teemu Likonen <tlikonen@iki.fi> - 2015-12-30 10:57 +0200
  Re: Scope of "this" variable Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-29 22:09 +0100
  Re: Scope of "this" variable Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-12-29 19:38 -0200
    Re: Scope of "this" variable Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-12-29 19:46 -0200
      Re: Scope of "this" variable Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-30 00:42 +0100
    Re: Scope of "this" variable Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-30 00:35 +0100
    Re: Scope of "this" variable Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-12-30 02:18 -0200

csiph-web