The above example is exactly how not to set the event bindings. Use delegation as suggested earlier…
See also: In Depth - Event Delegation in JavaScript
Here is something to consider so you can assign a new id to every new class member.
let memberId = 0
class Member {
static setId() {
return ++memberId;
}
constructor(name) {
this.name = name;
this.memberId = Member.setId();
}
}
const bill = new Member("Bill Bourne");
const bob = new Member("Bob Jackson");
Native Browser JavaScript
>
=> undefined
> bill.memberId
=> 1
> bob.memberId
=> 2