How to remove an object

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

Hello, and welcome, @ats3788!

JavaScript is a garbage-collected 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:

b = undefined;

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

1 Like

THank you Sven This is odd for me.