paint-brush
The Magic of Iterators: Build Python range() in JavaScript by@guyariely
172 reads

The Magic of Iterators: Build Python range() in JavaScript

by Guy Ariely3mAugust 5th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Python range() refers to the use of the range type to create an immutable sequence of numbers. The range() constructor has two forms of definition: range(stop) and range(start, stop[, step) The Python examples above wrap the return value of range with list(). An equal example in JavaScript should probably look something like this: Array.from(range(1, 11) The result is a simple one-liner: Array(stop - start).fill(start).map((el, i) => el + i)

Company Mentioned

Mention Thumbnail
featured image - The Magic of Iterators: Build Python range() in JavaScript
Guy Ariely HackerNoon profile picture
Guy Ariely

Guy Ariely

@guyariely

Web Developer and Computer Science student 👨🏻‍💻

About @guyariely
LEARN MORE ABOUT @GUYARIELY'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Guy Ariely HackerNoon profile picture
Guy Ariely@guyariely
Web Developer and Computer Science student 👨🏻‍💻

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Coffee-web
Cyberfishnews
Lzomedia