Solved

accessing array in array items

Posted on 2014-09-03
3
165 Views
Last Modified: 2014-09-03
How can I access an array item in another array?
How can access ["AC1", "AC2"],["BC1", "BC2"], and ["DD1", "DD2"] from the ListOfColumns array below?

Ex:
<script type="text/javascript">
	var ListOfColumns = [["AA", "AB", ["AC1", "AC2"], "AD AE"], ["BB", "BB", ["BC1", "BC2"], "BD BE"], ["CA", "CB", "CC"], ["DD", "DE", ["DD1", "DD2"]]];
	console.log(ListOfColumns);
	console.log("[0]: "+ListOfColumns[0]);
	console.log("[0][0]: "+ListOfColumns[0][0]);
	console.log("[0][1]: "+ListOfColumns[0][1]);
	console.log("[0][2]: "+ListOfColumns[0][2]);
	console.log("[0][3]: "+ListOfColumns[0][3]);
	console.log("[1]: "+ListOfColumns[1]);
	console.log("[1][0]: "+ListOfColumns[1][0]);
	console.log("[1][1]: "+ListOfColumns[1][1]);
	console.log("[1][2]: "+ListOfColumns[1][2]);
	console.log("[1][3]: "+ListOfColumns[1][3]);
	console.log("[2]: "+ListOfColumns[2]);
	console.log("[3]: "+ListOfColumns[3]);
</script>

Open in new window

0
Comment
Question by:Isaac
  • 2
3 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 40301419
Check :

console
0
 
LVL 5

Author Comment

by:Isaac
ID: 40301530
I was able to do that.
I think I explained it wrong.

How do I access just "AC1", "BC1" or "DD1"?
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40301534
var ac1 = ListOfColumns[0][2][0];
var bc1 = ListOfColumns[1][2][0];
var dd1 = ListOfColumns[3][2][0];
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now