I'm wondering for some time now why this fails:
if (longest.length >= 3) {
for ( var i = 0; i < longest.length-1; i++) {
var $last[i] = longest[i].splice(-1).toString();
//if ( $( $last[i] ).closest(':jqmData(role="panel")') == "popover" ) {
//var gotoPage = $last[i];
// }
}
}
longest
is an array, which contains array elements.
I want to loop through the number of arrays in longest
and create variables from each nested arrays' last element. The .splice(-1).toString() fails telling me "missing ; before statement"
What am I doing wrong?
EDIT: longest will look something like this:
[[#menu, #menuSub1, #menuSub2], [#main, yield, yield], [#pop1, #pop1-1, #pop1-2]]
It's within a function to track the browser-history in a mobile-app with different panels.
EDIT2: Finished code (Thx Mic):
if (longest.length >= 3) {
var $last = [];
for ( var i = 0; i < longest.length; i++) {
$last.push( longest[i][ longest[i].length - 1 ]);
if ( $( $last[i] ).closest(':jqmData(role="panel")').jqmData('panel') == "popover" ) {
var gotoPage = $last[i]; }
}
}