javascript - slice not working as expected on my array -


i have array scraped webpage:

myvar = document.queryselectorall('#tblitinerarymodulestaydetail > tbody > tr') 

which in console returns array: enter image description here

what need subset array:

  1. start 3rd item
  2. then keep every odd number of items

so need subset of var items 3 , 5 in it.

i tried: myvar.slice(3,5). returned error "undefined not function"

had been successful have array 3 items. i'd need subset on keeping odd items in array.

how subset myvar have variable items 3 , 5 left in it? if myvar length 10. how subset include items 3, 5, 7, 9?

myvar = document.queryselectorall('#tblitinerarymodulestaydetail > tbody > tr') 

myvar nodelist , it's not array. can't use array functions in there.

but can use apply or call array functionality on nodelist.

how functionality?

array.prototype.slice.call(myvar, 3,5); 

now can use slice in nodelist.

but actual question, subset matching particular criteria not possible via slice well.

you must iterate through elements , manually.


Comments

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -