Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8240733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:35:28+00:00 2026-06-07T20:35:28+00:00

I want to declare an array having integer elements 1 to n, where n

  • 0

I want to declare an array having integer elements 1 to n, where n can be 100 or greater. So, its obvious that I don’t want to add all integers (1 to 100) manually.

Can someone suggest me the simplest way to do this in javascript?
I think there should be something like this: [1..n], but its not working.

EDIT:

MORE CLARIFICATION OF REQUIREMENT:

I need this: var arr = [1,2,3,4,5,6,7,8,9,10,11,....,100] but I don’t want to declare like this where I have to write every element manually. I need something better option to do this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T20:35:30+00:00Added an answer on June 7, 2026 at 8:35 pm

    You could do this like:

    var i = new Array(10);
    for ( var j = 0; j < i.length; j++) {
        i[j] = j + 1;
    }
    

    Just create an array and fill them with a for loop. You don’t have to declare the var at the beginning.

    Check This Example. See the result in the console

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to declare a global array so I can use this in all
I can declare NSMutableArray or NSArray but I want to declare class array. Let
i want to declare a parametrized method array or method list. This means that
I want to declare a pointer to an integer array in the header file
I'm trying to call method from .jar But when I want to declare array
I want to declare an array of handel as the following code: using namespace
I can: declare @idOrder int set @idOrder = 21319 I want: declare @idOrder int
I want to declare an array of strings but Java is complaining when I
I'm writing an app for iPhone in objective-c. I want to declare an array
I want to declare a hashmap in javascript with <String, String array> instead of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.