Reputation: 1427
Been a long time reader of Stack overflow but have never joined and asked a question but I guess there's a first time for everything.
I'm currently having an issue with an array in JS that is being used to store Twitter, Instagram and Pinterest feeds, as well as their timestamps.
Here is how the array was created...
var array = [];
Here is an example of how the feed and time is inserted into the array...
for (i < 0; i < 10; i++) {
array[i] = [feed, time] };
The array I'm getting looks something like this...
[[0[0][1]]]
[[1[0][1]]]
[[2[0][1]]]
When I console log the following...
console.log(array[[5]]);
I get this response...
["<a href="http://www.twi...ontrolled through diet.", "145339"]
How can I get the "145339" part just by itself?
I tried "console.log(array[[5[1]]])"
but I get the message "undefined".
Upvotes: 0
Views: 221
Reputation: 19282
Use the split()
method of javascript
var part = array[[5]];
var arr = part.split(',')
console.log(arr[1]);
Upvotes: 0
Reputation: 6516
For accessing members of a multidimensional array, the syntax you are looking for is more like array[5][1]
. I can't tell from your code exactly what the correct answer is but it looks like your syntax is the issue.
Upvotes: 2