senooken JP Social
  • FAQ
  • Login
senooken JP Socialはsenookenの専用分散SNSです。
  • Public

    • Public
    • Network
    • Groups
    • Popular
    • People

Conversation

Notices

  1. [ニューウェーブ]硫酸鶏 (ac@imastodon.net)'s status on Friday, 08-Feb-2019 18:51:19 JST [ニューウェーブ]硫酸鶏 [ニューウェーブ]硫酸鶏

    本当に面白い言語だよJSは。

    In conversation Friday, 08-Feb-2019 18:51:19 JST from imastodon.net permalink

    Attachments


    1. https://img.pawoo.net/media_attachments/files/012/055/215/original/84c14261b85259d3.png
    • 上風連 repeated this.
    • [ニューウェーブ]硫酸鶏 (ac@imastodon.net)'s status on Friday, 08-Feb-2019 18:55:14 JST [ニューウェーブ]硫酸鶏 [ニューウェーブ]硫酸鶏
      in reply to

      [[][[]]+[]][+[]][+[]]

      をまず

      _=[][[]];[_+[]][+[]][+[]]

      という感じに分けて考えます。

      []は空の配列を生成し、後続の[[]]がこれに対して[]をキーとしてアクセスするので、当然undefinedになります。よって

      [undefined+[]][+[]][+[]]

      という感じになります。ここで

      undefined+[]

      ですが、両辺がNumberでないためにtoStringが暗黙的に呼び出され文字列結合されます。ただしArray.prototype.toStringはArray.prototype.joinと等価の結果を返すため、空の配列から得られる文字列は空文字列となります。よって

      ['undefined'][+[]][+[]]

      という感じになります。更にここで

      +[]

      ですが、接頭につく+は空文字列を0に変換する効能を持つため、空配列が文字列化された上で0になります。よって

      'undefined'[+[]]

      となり、'undefined'という文字列の0番目にアクセスするため

      'u'

      となります。

      In conversation Friday, 08-Feb-2019 18:55:14 JST permalink
      上風連 repeated this.

Feeds

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

senooken JP Social is a social network, courtesy of senooken. It runs on GNU social, version 2.0.2-beta0, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All senooken JP Social content and data are available under the Creative Commons Attribution 3.0 license.