Metody prywatne JS

// Define class
class Car {
	// Initial parameters
    constructor(x, y) {
      this.x = x;
      this.y = y;
      this.acc = 0.2;
      this.speed = 0;
      this.crashed = false;
    }
  	// Public method
  	update() {
      this.#move();
      this.crashed = this.#detectCollisions();
    }
  	// Private method using '#'
  	#move() {
    	this.speed += this.acc;	
	}
    // Private method using '#'
    #detectCollisions() {
    	return getCollisions(this.x, this.y, traffic.x, traffic.y);
	}
}

// Calling Car class
var car = new Car(0, 0);
// Public method update calls private methods
car.update();
ItsDr4g0n