# How to remove an object

**URL:** <https://discourse.processing.org/t/how-to-remove-an-object/23733>\
**Category:** Beginners\
**Created:** [September 8, 2020, 5:56am UTC](https://discourse.processing.org/t/how-to-remove-an-object/23733 "2020-09-08T05:56:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ats3788](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@ats3788](https://discourse.processing.org/u/ats3788)\
**Post date:** [September 8, 2020, 5:56am UTC](https://discourse.processing.org/t/how-to-remove-an-object/23733/1 "2020-09-08T05:56:22Z")

</div>

Hello  
I create an object like this

let balls = [];  
b = new Ball(random(150, ScreenX) , 0, r, red, green, blue);

but how can I free / remove this Object

---

<div class="post-metadata">

**Author:** ![Sven](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sven/32/8293_2.png) [@Sven](https://discourse.processing.org/u/Sven)\
**Post date:** [September 8, 2020, 7:07am UTC](https://discourse.processing.org/t/how-to-remove-an-object/23733/2 "2020-09-08T07:07:16Z")

</div>

Hello, and welcome, @ats3788!

JavaScript is a [garbage-collected](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) language, so you don’t have to explicitly remove or free the object. The object will be kept around as long as something is referencing it.

What you can do is make sure that nothing is referencing the object, like:

```javascript
b = undefined;

```

With no more references, the garbage collector will eventually take care of and free the memory.

---

<div class="post-metadata">

**Author:** ![ats3788](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@ats3788](https://discourse.processing.org/u/ats3788)\
**Post date:** [September 8, 2020, 8:57am UTC](https://discourse.processing.org/t/how-to-remove-an-object/23733/3 "2020-09-08T08:57:00Z")

</div>

THank you Sven This is odd for me.
