[program-l] Re: array.splice is not a function?

  • From: Soronel Haetir <soronel.haetir@xxxxxxxxx>
  • To: program-l@xxxxxxxxxxxxx
  • Date: Tue, 11 Jan 2022 10:02:11 -0900

My docs say Array has 'slice', not 'splice'.

That being said, I would expect you to have better luck using
Array.filter, takes a callback function and an optional 'this'
parameter and returns an array with all elements for which the
callback return is not false.

On 1/11/22, Erik Burggraaf <burggraaferik@xxxxxxxxx> wrote:

Hi all,  I just tried to remove items from an array of html elements using
splice() and got this error that array.splice is not a function.  Any idea
why?  I've read four or five articles but nothing illuminating.

My situation is that I wanted to get elements by tag name so that I didn't
have to use a custom class.  So I swept the elements into an array and they
work just fine.  Unfortunately, there were more of the same, in this case
articles in my production environment than there are in my test
environment.  I don't need the extra ones, so thought splice would be an
easy way to pull them out.

I looped through the array, testing a condition.  If they meet the
condition they get pulled out.  Otherwise they stay.

But the splice method is not a function or so I'm told by my error console.

Any suggestions very much appreciated as always.

Thanks,

Erik



-- 
Soronel Haetir
soronel.haetir@xxxxxxxxx
** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

Other related posts: