Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Teemu Likonen 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> 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 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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=20Common 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. =2D-=20 /// Teemu Likonen - .-.. // // PGP: 4E10 55DC 84E9 DFF6 13D7 8557 719D 69D3 2453 9450 /// --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJWg5xzAAoJEHGdadMkU5RQ2oMQAKlAizh5sCj8+eQWSdzusWB3 nE7f3FMfzW9zI0q1Mf7ucycNAr8pcaBq4hpZdbCbmnfY+nsvWA2G1V7vcwKKgtwD 9yBnevoeHS6KOp2fIUKN5TduH0XU9edP6bY7Es3y7QRozbAAYzzUeoVKpE9IEY53 Eh9RdACYxnk7RQmrYINo/QQqj1RdKnS4faGxoHEn5obtEAvWRdDd579qhXb/dM1R RVJ8K60oZf6FnxPhnZkwjjXkEyHsjyAtwMNRtMT+yjdaf8VLpV/830IdvgFfasT2 C8RCfbjPDadUtXHGo0xaGQ5fg+agrsCJCg8Iw/qPt4B0hnL4a9dLWqf/yvk+SDCK 4Yygmm1IGS5CEEirUewLkZ2pE55AlMu2DJeGA5vmQiK993hRVxr1RT7lTkrS7t36 BNLUJYQjJxGiEI1vbdlNfYBmn1Wg08IWNf+OonR0ofX/uHVpYCC0Mgg80b2nt2sp Xk7hd9zCZpYYjcyzVKG2ZR3o+WAnts8pR7TTlcDkL/jNATwTAP0f8FTFA6YsO3pC E61+afyAAIPtHD/WPr9r5Z32pN+66mwcWAuzugVz+AvAPGUNVGpbyDKMPDGOWoPn f+3qRIULQw1fyLXbeO4gwbE834+ddrJOoJdglNvJuO+8fdAXLjjwzS+bsKZLIjbe rU2K7Wk6p6XyJj1MiPXI =zo45 -----END PGP SIGNATURE----- --=-=-=--