Lemmy LIETUVA
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
codeinabox@programming.dev to JavaScript@programming.devEnglish · 4 months ago

Why I don't chain everything in JavaScript anymore

allthingssmitty.com

external-link
message-square
13
link
fedilink
1
external-link

Why I don't chain everything in JavaScript anymore

allthingssmitty.com

codeinabox@programming.dev to JavaScript@programming.devEnglish · 4 months ago
message-square
13
link
fedilink
Why I don't chain everything in JavaScript anymore - Matt Smith
allthingssmitty.com
external-link
JavaScript chaining looks clean at first, but it can hurt readability and hide extra work. Here's when to break chains into simpler steps.
  • Dumhuvud@programming.dev
    link
    fedilink
    English
    arrow-up
    0
    ·
    3 months ago

    You made me go down the rabbit hole with that question. TIL the very same methods exist on Iterator’s prototype. They aren’t eager, no.

    You can get an iterator out of an array with Array.prototype[Symbol.iterator]() and you can collect an iterator into an array with Iterator.prototype.toArray().

    • Thinker@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      3 months ago

      One reason you may not have known this is that these (iterator methods, not the Iterator itself) are newish additions to Javascript and only available in all the big browsers for just over 1 year.

JavaScript@programming.dev

javascript@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !javascript@programming.dev
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 2 users / day
  • 5 users / week
  • 14 users / month
  • 66 users / 6 months
  • 0 local subscribers
  • 2.76K subscribers
  • 114 Posts
  • 69 Comments
  • Modlog
  • mods:
  • Erlingur@programming.dev
  • Ategon@programming.dev
  • nick@programming.dev
  • BE: 0.19.18
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org