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

Why I don't chain everything in JavaScript anymore

allthingssmitty.com

external-link
message-square
12
link
fedilink
9
external-link

Why I don't chain everything in JavaScript anymore

allthingssmitty.com

codeinabox@programming.dev to JavaScript@programming.devEnglish · 8 days ago
message-square
12
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
    6
    ·
    7 days 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
      2
      ·
      7 days 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.

  • 3 users / day
  • 22 users / week
  • 89 users / month
  • 383 users / 6 months
  • 1 local subscriber
  • 2.71K subscribers
  • 288 Posts
  • 487 Comments
  • Modlog
  • mods:
  • Erlingur@programming.dev
  • Ategon@programming.dev
  • nick@programming.dev
  • BE: 0.19.14
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org