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
    Axel Rauschmayer (rauschma@fosstodon.org)'s status on Saturday, 30-Dec-2023 05:36:00 JST Axel Rauschmayer Axel Rauschmayer

    Making sense of “senseless” JavaScript features:

    – 0.1 + 0.2 and the floating point format
    – Type coercion
    – Automatic semicolon insertion
    – Why so many bottom values?
    – Increment (++) and decrement (--)

    https://www.smashingmagazine.com/2023/12/making-sense-of-senseless-javascript-features/

    #JavaScript

    In conversation Saturday, 30-Dec-2023 05:36:00 JST from fosstodon.org permalink

    Attachments

    1. Domain not in remote thumbnail source whitelist: files.smashing.media
      Making Sense Of “Senseless” JavaScript Features — Smashing Magazine
      from https://www.smashingmagazine.com/author/juan-diego-rodriguez/
      JavaScript may be the most popular client-side language in the world, but it’s far from perfect and not without its quirks. Juan Diego Rodriguez examines several “absurd” JavaScript eccentricities and explains how they made it into the language as well as how to avoid them in your own code.
    • Embed this notice
      Axel Rauschmayer (rauschma@fosstodon.org)'s status on Saturday, 30-Dec-2023 05:35:58 JST Axel Rauschmayer Axel Rauschmayer
      in reply to

      2/ Note that we can create our own special “parameter is missing” values via default parameter values (=we don’t really need a built-in `undefined`):

      const MISSING = Symbol('MISSING');
      function f(param = MISSING) {
      return param === MISSING ? 'MISSING' : param;
      }

      Using this function:

      > f()
      'MISSING'
      > f(undefined) // also triggers the default value
      'MISSING'
      > f(null)
      null
      > f('abc')
      'abc'

      In conversation Saturday, 30-Dec-2023 05:35:58 JST permalink
    • Embed this notice
      Axel Rauschmayer (rauschma@fosstodon.org)'s status on Saturday, 30-Dec-2023 05:35:59 JST Axel Rauschmayer Axel Rauschmayer
      in reply to

      1/ W.r.t. optional parameters, JavaScript having both `undefined` and `null` becomes useful because we can distinguish between a parameter being `null` and it being omitted. (Probably not enough of an upside to outweigh the downsides elsewhere.)

      In light of this, I’m wondering if we should try to never explicitly use `undefined`—unless we need to skip a positional parameter:

      func(1, undefined, 3)

      Often better: named parameters (see link below).

      https://exploringjs.com/impatient-js/ch_callables.html#parameter-handling

      In conversation Saturday, 30-Dec-2023 05:35:59 JST permalink
      esmevane, sorry repeated this.
    • Embed this notice
      Sergey Shandar (functionalscript@techhub.social)'s status on Saturday, 30-Dec-2023 15:13:09 JST Sergey Shandar Sergey Shandar
      in reply to

      @rauschma would it be better to use `(void) 0` instead?

      In conversation Saturday, 30-Dec-2023 15:13:09 JST permalink

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.