Extracting data from Multidimensional arrays


#1

Hi guys, do you know how to extract data from multidim arrays?
Example:

var newArray = [[1, 2, "john"], ["pizza", "guy", true, false, papyrus = {job: "friend"}]];

console.log(newArray);

How to extract papyrus object only?

Thank you in advance!


#2

The array it's stored in:

newArray

2nd Item

newArray[1] //Starts at 0

5th In that array

newArray[1][4] //Starts at 0

Log information:

console.log(newArray[1][4]);

Finished! :slightly_smiling:


#3

Well you actually assigned a value to the name papyrus so..
console.log(papyrus);

The value is also added to the array because the return value of assignment is the assigned value.

For example:

console.log(a = 5) // prints 5


#4

Thank you guys or girls! :slightly_smiling: