Declare a new array in JavaScript with a var as its size

totally new to JS but need to use it atm.

In C language I can declare new arrays the following way: int A[10], B[A];

This way I can create custom sized arrays of a variable.

Is it possible to do the same with JavaScript? I need to make an Array with the size of a variable.
I tried to do stuff like: var n = 10; var A = new Array(n); but it just doesn’t work.
Thanks.

87 thoughts on “Declare a new array in JavaScript with a var as its size”

  1. I loved as much as you’ll receive carried out right here.
    The sketch is tasteful, your authored subject matter stylish.

    nonetheless, you command get got an impatience over
    that you wish be delivering the following.
    unwell unquestionably come more formerly again as exactly the same nearly very often inside case you shield this hike.

    Reply
  2. Very nice post. I simply stumbled upon your weblog
    and wanted to mention that I have really enjoyed surfing around your weblog posts.
    In any case I’ll be subscribing to your feed and I am hoping you write again soon!

    Reply
  3. It is in reality a nice and useful piece of info. I am happy that you shared this useful information with us.
    Please keep us up to date like this. Thanks for sharing.

    Reply
  4. Excellent blog here! Also your web site loads up very fast!

    What host are you using? Can I get your affiliate link to your host?
    I wish my site loaded up as fast as yours lol

    Reply
  5. Howdy! This article couldn’t be written any better!
    Going through this post reminds me of my previous roommate!
    He always kept preaching about this. I’ll forward this information to him.

    Fairly certain he’s going to have a good read.
    I appreciate you for sharing!

    Reply
  6. Hello! This is my first visit to your blog! We are a team of volunteers and
    starting a new initiative in a community in the same niche.
    Your blog provided us useful information to work on. You have done
    a extraordinary job!

    Reply
  7. First of all I would like to say awesome blog! I had a quick question in which I’d
    like to ask if you don’t mind. I was interested to know how you center yourself and
    clear your mind prior to writing. I’ve had a difficult time clearing my
    mind in getting my ideas out. I do enjoy writing however it just
    seems like the first 10 to 15 minutes are generally wasted simply just trying
    to figure out how to begin. Any ideas or
    hints? Cheers!

    Reply
  8. Great post. I was checking continuously this blog and I am impressed!
    Extremely helpful information specially the last part 🙂 I care for such
    information much. I was seeking this particular information for a
    very long time. Thank you and good luck. scoliosis
    surgery https://0401mm.tumblr.com/ scoliosis surgery

    Reply
  9. Hmm it appears like your site ate my first comment (it
    was extremely long) so I guess I’ll just sum it up what I wrote
    and say, I’m thoroughly enjoying your blog. I too
    am an aspiring blog blogger but I’m still new to everything.
    Do you have any recommendations for newbie blog writers?
    I’d really appreciate it. quest bars http://bitly.com/3C2tkMR quest
    bars

    Reply
  10. Pingback: free viagra
  11. Pingback: sildenafil 100mg
  12. Pingback: cialis 2.5 mg
  13. Pingback: cialis capsule
  14. Pingback: cialis by mail
  15. Pingback: sildenafil 20mg
  16. Pingback: buy viagra
  17. Pingback: generic for viagra

Leave a Comment