# Remove element from array

**URL:** <https://forum.kirupa.com/t/remove-element-from-array/132406>\
**Category:** Uncategorized\
**Created:** [December 28, 2004, 9:59am UTC](https://forum.kirupa.com/t/remove-element-from-array/132406 "2004-12-28T09:59:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tofuisonmyside](https://avatars.discourse-cdn.com/v4/letter/t/58956e/32.png) [@tofuisonmyside](https://forum.kirupa.com/u/tofuisonmyside)\
**Post date:** [December 28, 2004, 9:59am UTC](https://forum.kirupa.com/t/remove-element-from-array/132406/1 "2004-12-28T09:59:26Z")

</div>

Hello kirupers,

i am trying to remove elements form an array.  
the array is kind of special: content depends on what you have clicked or not:

see some code:

pArr = [];  
for(var i =0;i\<max;i++){  
johndoe\*.pressed = false;  
johndoe\*.onPress = function(){  
this.pressed = !this.pressed;  
if(this.pressed){  
pArr.push(this.obj)  
}else{  
pArr.remove(this.obj);  
}  
}  
}

of course the remove function is my pb, not done yet.

i have tested some proto on it, but cannot figure it properly.

How can i remove the same object from the array, knowing that the array can contain several times the same object, so i do not want to delete it many times but just the good one ? so the trick is to remove only the object associated with the johndoe button.

maybe the pb comes from the way i push the elements ?

thx for your reading so far, hope this is an understanding problem.  
tofu.
