It is not appropriate to use an object here, because it provides no methods to manage the order of elements. for (num=0;num .

JavaScript Array Method . var my_array=["Dhoni","Sachin","Rohit","Dhawan"];

. In Pass by Reference, Function is called by directly passing the reference/address of the variable as the argument. country[0] = "India"; So to make code clean and also to pass an array as a function argument, the spread operator comes in to picture. The fill() method is used to fill the specified static values by modifying original values in the given array. The this value provides a call to the function and the arguments array contains the array of arguments to be passed. How to pass a PHP array to a JavaScript function? country[3] = "New Zealand"; Pass arguments from array in PHP to constructor.

© 2020 - EDUCBA. document.write(country[num] + "
"); var vals=[150,400,450,375,200]; document.writeln(my_array); var my_array = ['India', 'Srilanka', 'England']; The last element will become the first and the first element will become last. . Start Your Free Software Development Course, Web development, programming languages, Software testing & others. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy, Learn from Home Offer - JavaScript Training Program (39 Courses, 23 Projects) Learn More, JavaScript Training Program (39 Courses, 23 Projects, 4 Quizzes), 39 Online Courses | 23 Hands-on Projects | 225+ Hours | Verifiable Certificate of Completion | Lifetime Access | 4 Quizzes with Solutions, Angular JS Training Program (9 Courses, 7 Projects), Software Development Course - All in One Bundle.

my_array.push("Srilanka"); If you want to create websites or portal — contact us @ https://www.bondesk.in. Arrays in JavaScript are used to store an information set, but it is often more helpful for storing a set of variables of the same type. Number, string, boolean, null, undefined, object, function, regular document.writeln(my_array); . You can also go through our other suggested articles to learn more, JavaScript Training Program (39 Courses, 23 Projects). var array_result=my_array.shift(); In Pass by Value, Function is called by directly passing the value of the variable as the argument. } But sometimes we need an ordered collection, where we have to store 1st, 2nd, 3rd element and many more.

document.writeln(array_result);

How to pass a function as a parameter in Java. As a global object, the JavaScript Array can be used in the construction of arrays that are high-level.