cancel
Showing results for 
Search instead for 
Did you mean: 

array/list

Highlighted
New Contributor

array/list

hi, how can i create array or list of arrays by jscript?

3 REPLIES 3
Highlighted
Valued Contributor

Re: array/list

function twoDimArrays()
{
  var vehicals = [["Toyota", "Nissan","Volvo"],["Honda","Yamaha","Halidavidson"]];
  Log.Message(vehicals[1][1]);
  
}

https://stackoverflow.com/questions/966225/how-can-i-create-a-two-dimensional-array-in-javascript 

Highlighted
New Contributor

Re: array/list

Thanx but I didnt mean to matrix... I need to create an array with value=0 and insert the value at a specific index.

How do iI first create the array and how can I insert value to the specific index?

Highlighted
Community Hero

Re: array/list

Check out below... basic JScript/JavaScript array operations.

function demoArray(){
var myArray = [];
myArray.length = 5; // sets the array to have 5 elements
myArray[2] = 0; // sets the 3rd element (with index of 2) to value of 0
}

Might be worth checking out https://www.w3schools.com/js/js_arrays.asp and related links... I know it says "JavaScript" but JScript is just, for all intents and purposes, an old version of JavaScript.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!

Retrieve Data from a Web Page

Participate!
Top Kudoed Authors