GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    Aral Balkan (aral@mastodon.ar.al)'s status on Thursday, 31-Aug-2023 18:26:18 JST Aral Balkan Aral Balkan

    Ran into this basic JavaScript scope gotcha today.

    Just goes to show, you could be programming in a language for years and still get tripped up by some of the simplest issues.

    https://codeberg.org/aral/gists/src/branch/main/javascriptScope.md

    #JavaScript #scope #web #dev

    In conversation Thursday, 31-Aug-2023 18:26:18 JST from mastodon.ar.al permalink
    • Embed this notice
      Aral Balkan (aral@mastodon.ar.al)'s status on Thursday, 31-Aug-2023 18:33:51 JST Aral Balkan Aral Balkan
      in reply to
      • Ekaitz Zarraga 👹

      @ekaitz_zarraga Yeah ;)

      “It looks like it’s going to work because we’re used to things being hoisted in JavaScript but that only goes for functions.”

      In conversation Thursday, 31-Aug-2023 18:33:51 JST permalink
    • Embed this notice
      Ekaitz Zarraga 👹 (ekaitz_zarraga@mastodon.social)'s status on Thursday, 31-Aug-2023 18:33:52 JST Ekaitz Zarraga 👹 Ekaitz Zarraga 👹
      in reply to

      @aral If you want to learn more about it, it happens because `const` doesn't apply hoisting in the way you are expecting it to:
      https://developer.mozilla.org/en-US/docs/Glossary/Hoisting

      In conversation Thursday, 31-Aug-2023 18:33:52 JST permalink

      Attachments

      1. Domain not in remote thumbnail source whitelist: developer.mozilla.org
        Hoisting - MDN Web Docs Glossary: Definitions of Web-related terms | MDN
        from MozDevNet
        JavaScript Hoisting refers to the process whereby the interpreter appears to move the declaration of functions, variables, classes, or imports to the top of their scope, prior to execution of the code.
    • Embed this notice
      Aral Balkan (aral@mastodon.ar.al)'s status on Thursday, 31-Aug-2023 18:34:54 JST Aral Balkan Aral Balkan
      in reply to
      • Ekaitz Zarraga 👹

      @ekaitz_zarraga Although, thanks for the link, I’ll add it to the gist :)

      In conversation Thursday, 31-Aug-2023 18:34:54 JST permalink
    • Embed this notice
      Aral Balkan (aral@mastodon.ar.al)'s status on Thursday, 31-Aug-2023 18:37:02 JST Aral Balkan Aral Balkan
      in reply to
      • Ekaitz Zarraga 👹
      • Piggo :verified_horse:

      @ekaitz_zarraga @piggo Thanks, folks, updated the gist with your contributions:

      https://codeberg.org/aral/gists/src/branch/main/javascriptScope.md

      In conversation Thursday, 31-Aug-2023 18:37:02 JST permalink
    • Embed this notice
      Ekaitz Zarraga 👹 (ekaitz_zarraga@mastodon.social)'s status on Thursday, 31-Aug-2023 18:38:51 JST Ekaitz Zarraga 👹 Ekaitz Zarraga 👹
      in reply to

      @aral it's not only for functions. It's way more complex than that.
      It's a lot of fun.

      In conversation Thursday, 31-Aug-2023 18:38:51 JST permalink
    • Embed this notice
      Aral Balkan (aral@mastodon.ar.al)'s status on Thursday, 31-Aug-2023 18:38:51 JST Aral Balkan Aral Balkan
      in reply to
      • Ekaitz Zarraga 👹

      @ekaitz_zarraga Yay! :)

      In conversation Thursday, 31-Aug-2023 18:38:51 JST permalink
    • Embed this notice
      Aral Balkan (aral@mastodon.ar.al)'s status on Thursday, 31-Aug-2023 19:18:22 JST Aral Balkan Aral Balkan
      in reply to
      • Jeroen Baert

      @jbaert Yeah, hoisting is fun (when it works) :)

      In conversation Thursday, 31-Aug-2023 19:18:22 JST permalink
    • Embed this notice
      Jeroen Baert (jbaert@mastodon.social)'s status on Thursday, 31-Aug-2023 19:18:23 JST Jeroen Baert Jeroen Baert
      in reply to

      @aral Shouldn't even be able to call greet() in the first place! Undeclared!

      *strokes long beard*

      In conversation Thursday, 31-Aug-2023 19:18:23 JST permalink
    • Embed this notice
      Jeroen Baert (jbaert@mastodon.social)'s status on Thursday, 31-Aug-2023 19:18:24 JST Jeroen Baert Jeroen Baert
      in reply to

      @aral Me, as a C developer, not blinking: "Well of course!"

      In conversation Thursday, 31-Aug-2023 19:18:24 JST permalink
    • Embed this notice
      Ekaitz Zarraga 👹 (ekaitz_zarraga@mastodon.social)'s status on Thursday, 31-Aug-2023 19:19:20 JST Ekaitz Zarraga 👹 Ekaitz Zarraga 👹
      in reply to

      @aral btw I know this because I've been teaching JS... if I didn't I wouldn't know about this.
      These concepts are hard to find or learn about if you are just coding on JS.

      In conversation Thursday, 31-Aug-2023 19:19:20 JST permalink
    • Embed this notice
      Aral Balkan (aral@mastodon.ar.al)'s status on Thursday, 31-Aug-2023 19:19:20 JST Aral Balkan Aral Balkan
      in reply to
      • Ekaitz Zarraga 👹

      @ekaitz_zarraga Yeah, teaching is the best way to learn ;)

      In conversation Thursday, 31-Aug-2023 19:19:20 JST permalink
    • Embed this notice
      Aral Balkan (aral@mastodon.ar.al)'s status on Thursday, 31-Aug-2023 22:33:01 JST Aral Balkan Aral Balkan
      in reply to
      • David Hayes :prami:

      @drhayes Ooh, I like that :)

      In conversation Thursday, 31-Aug-2023 22:33:01 JST permalink
    • Embed this notice
      David Hayes :prami: (drhayes@social.lol)'s status on Thursday, 31-Aug-2023 22:33:03 JST David Hayes :prami: David Hayes :prami:
      in reply to

      @aral I'm sure you're sick of people popping in to explain this at you, so I won't do that.

      But I *will* say this has the coolest name of anything I know of in programming: it's the TEMPORAL DEAD ZONE!

      A touch of Star Trek in our JavaScript!

      In conversation Thursday, 31-Aug-2023 22:33:03 JST permalink
    • Embed this notice
      Aral Balkan (aral@mastodon.ar.al)'s status on Thursday, 31-Aug-2023 22:38:47 JST Aral Balkan Aral Balkan
      in reply to
      • David Hayes :prami:

      @drhayes Just updated the gist with a reference to your toot and the MDN explanation of Temporal Dead Zone :) Thanks again :)

      https://codeberg.org/aral/gists/src/branch/main/javascriptScope.md

      In conversation Thursday, 31-Aug-2023 22:38:47 JST permalink

      Attachments

      1. Domain not in remote thumbnail source whitelist: codeberg.org
        gists
        from aral
        A place for me to post and share small, self-contained code snippets.

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.