How to create arrays in JavaScript?

  • : 378
  • : 15
    Previous Next

    There are two ways to create array in JavaScript like other languages:
    a) The first way to create array
    Declare Array:
    var names = new Array();
    Add Elements in Array:-
    names[0] = "Vikas";
    names[1] = "Ashish";
    names[2] = "Nikhil";

    b) This is the second way:
    var names = new Array("Vikas", "Ashish", "Nikhil");

    you can suggest other answer in comment box

  • Exam: Java Script Interview QUESTIONS

    Recommended Learning for you

    Subscribe here for free mock test on IAS PCS SSC and other competitive exam. Signup here to get SSC CGL Solution and main exam study material