# Is there a built-in function in JavaScript for creating sequences like Python's range()?

**URL:** <http://community.latenode.com/t/is-there-a-built-in-function-in-javascript-for-creating-sequences-like-pythons-range/7188>\
**Category:** JavaScript\
**Created:** [March 11, 2025, 4:09pm UTC](http://community.latenode.com/t/is-there-a-built-in-function-in-javascript-for-creating-sequences-like-pythons-range/7188 "2025-03-11T16:09:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HappyDancer99](http://community.latenode.com/letter_avatar_proxy/v4/letter/h/ebca7d/32.png) [@HappyDancer99](http://community.latenode.com/u/HappyDancer99)\
**Post date:** [March 11, 2025, 4:09pm UTC](http://community.latenode.com/t/is-there-a-built-in-function-in-javascript-for-creating-sequences-like-pythons-range/7188/1 "2025-03-11T16:09:43Z")

</div>

Hey folks, I’m wondering if JavaScript has something similar to Python’s `range()` function. I want to create a sequence of numbers or letters easily.

In Python, you can do this:

```python
list(range(1, 4)) # [1, 2, 3]

```

And for letters:

```python
[chr(i) for i in range(ord('A'), ord('D'))] # ['A', 'B', 'C']

```

Is there a quick way to do this in JavaScript without writing a custom function? If not, what’s the best way to create such sequences? I’m new to JS and would appreciate any tips or tricks. Thanks!

---

<div class="post-metadata">

**Author:** ![Ethan\_19Chess](http://community.latenode.com/letter_avatar_proxy/v4/letter/e/c5a1d2/32.png) [@Ethan\_19Chess](http://community.latenode.com/u/Ethan_19Chess)\
**Post date:** [March 22, 2025, 5:14pm UTC](http://community.latenode.com/t/is-there-a-built-in-function-in-javascript-for-creating-sequences-like-pythons-range/7188/2 "2025-03-22T17:14:21Z")

</div>

JavaScript doesn’t have a built-in range() function like Python, but there are workarounds. One approach I’ve found useful is using Array.from() with a mapping function:

Array.from({length: 3}, (\_, i) =\> i + 1) // [1, 2, 3]

For letter sequences, you can combine charCodeAt() and String.fromCharCode():

let start = ‘A’.charCodeAt(0);  
let end = ‘D’.charCodeAt(0);  
Array.from({length: end - start}, (\_, i) =\> String.fromCharCode(start + i))

This produces [‘A’, ‘B’, ‘C’]. It’s not as straightforward as Python, but it’s efficient once you get used to it. These methods can be wrapped in custom functions for reusability if you find yourself needing them often.

---

<div class="post-metadata">

**Author:** ![ClimbingLion](http://community.latenode.com/user_avatar/community.latenode.com/climbinglion/32/430_2.png) [@ClimbingLion](http://community.latenode.com/u/ClimbingLion)\
**Post date:** [March 21, 2025, 2:01pm UTC](http://community.latenode.com/t/is-there-a-built-in-function-in-javascript-for-creating-sequences-like-pythons-range/7188/3 "2025-03-21T14:01:36Z")

</div>

yo, js doesn’t have a built-in range() like python, but u can use Array.from() for a quick fix. Like this:

Array.from({length: 3}, (\_, i) =\> i + 1) // [1, 2, 3]

for letters, it’s a bit trickier, but still doable. hope this helps!

---

<div class="post-metadata">

**Author:** ![OwenNebula55](http://community.latenode.com/letter_avatar_proxy/v4/letter/o/c89c15/32.png) [@OwenNebula55](http://community.latenode.com/u/OwenNebula55)\
**Post date:** [March 21, 2025, 8:39am UTC](http://community.latenode.com/t/is-there-a-built-in-function-in-javascript-for-creating-sequences-like-pythons-range/7188/4 "2025-03-21T08:39:12Z")

</div>

JavaScript doesn’t have a built-in range() function like Python, but there are some neat workarounds. I’ve found Array.from() to be pretty handy for creating number sequences:

Array.from({length: 3}, (\_, i) =\> i + 1) // gives [1, 2, 3]

For letter sequences, it’s a bit trickier. I usually go with something like this:

let start = ‘A’.charCodeAt(0);  
let end = ‘D’.charCodeAt(0);  
Array.from({length: end - start}, (\_, i) =\> String.fromCharCode(start + i))

This gives you [‘A’, ‘B’, ‘C’]. It’s not as straightforward as Python, but it gets the job done. Hope this helps!
