How to remove a position from an ArrayBuffer in javascript?

0

I have this ArrayBuffer below and I need to remove from that array the position that has the value 21

Have I tried to use splice(24,1) and also delete array[24] and none worked?

Does anyone know how I can only remove this position from ArrayBuffer ?

<Buffer 01 a6 31 35 cb 12 00 08 7d cb b8 ae c5 3e 2d 0e 1e d0 fe 29 4e 61 fd 01 21 a0 00 c0 03 00 00 00 00 00 00 00 00 00 04 24 03 19 15 cb 0b 3b 26 06 0b 31 00 ...>
    
asked by anonymous 09.11.2015 / 14:27

2 answers

0

Just use the '- =' operator. Let's say we have the following:

val valor = ArrayBuffer('1', '2', '3', '4', '21')

To delete the value 21:

valor -= '21'

If we want to delete more than one value:

valor -= ('21', '4')
    
09.11.2015 / 15:41
0

You can do so, it will remove the element from the array:

 ArrayBuffer.forEach(function(value, index) {
       if (value == '21') {
            ArrayBuffer.splice(index, 1);
       }
 });

See working here

    
09.11.2015 / 16:30