News for hackers. Stuff that matters.
Re:Deno Joins TC39 by wruza on Monday December 13, 2021 @05:27PM (#29545492)
Range a-la python is a generator and is pretty straightforward in js as is. There is no need for a complicated solution and/or as part of stdlib, imo:

  function* range(x, y) {
    while (x <= y) {yield x++}
    // or ‘<‘ if you want half-open one
  }

  for (let n of range(3, 5)){
    console.log(n)
  }

  array = [...range(3, 5)]
  console.log(array)
Re:Deno Joins TC39 by amitport on Tuesday December 14, 2021 @04:00AM (#29549684)
It's also straight forward to implement in python. It is common enough to be standard so people won't reinvent the wheel. And it should be available to people learning the language before they learn generators.

Array.prototype.indexOf is also pretty simple as are many core functions.