javascript - js slicing even number in array -
so, have object splitting, leaving comma in between.
i thought use slice select number position ignore comma:
alert(sample); // first_name|^&|last_name|^&| var test = sample.split('|^&|'); giving: first_name,last_name
however, comma counted array , giving me headache.
so, thought use slice select [0], [2], [4] , on, ignoring comma.
how select number? (var test = sample.split(',').slice(?);)?
you don't have commas in test elements
sample = 'first_name|^&|last_name|^&|'; test = sample.split('|^&|'); alert( test[ 0 ] ); // first_name alert( test[ 1 ] ); // last_name the issue may have there trailing separator |^&| in sample have empty element @ end of array...
alert( test[ 2 ] ); // (empty string) ...that may rid of just
test.pop(); // removes last item of array
Comments
Post a Comment