Creating a class with multiple constructors and static variables in JavaScript

I am familiar with Processing/Java but am trying to learn more p5.js/JavaScript. I am creating a class that, in Java, has multiple constructors with the same number of arguments with different data types.


class Card {
public class Card implements Comparator<Card> {
	public final static int SPADES = 0;
	public final static int HEARTS = 1;
	public final static int CLUBS = 2;
	public final static int DIAMONDS = 3;
	private int suit;
	private String card;
	private int value;
	public Card(int suit, String card) {
        //implementation not shown
	public Card(int suit, int value) {
        //implementation not shown

    //other methods not shown

I was wondering if there is any way to do something like this in JavaScript as you don’t explicitly state the variable type in the constructor.

Additionally, I was working in the p5.js web editor and started to try to make a class with static variables as such:

class Card {
  static SPADES = 0;
  static HEARTS = 1;
  static CLUBS = 2;
  static DIAMONDS = 3;

But I’m getting an error on line 2 ("Class properties must be methods. Expected “(” but instead saw “=”), but when I try to run this on normal JavaScript it says it’s fine. Maybe I’m just missing something…

Thank you for any help.

If you wanna have full access to the JS language, use something else: :smirk: