In javascript, I have these two approaches to group similar methods:
first approach:
class GroupedMethodsWithClass {
static a = () => {
console.log("a")
};
static b = () => {
console.log("b")
}
}
and the second one:
const GroupedMethodsWithObject = {
a() {
console.log("a");
},
b() {
console.log("b");
},
}
Right now I only know that I have the class static initialization block option with first approach:
class GroupedMethodsWithClass {
static a = () => {
console.log("a")
}
static b = () => {
console.log("b")
}
static {
console.log('Class static initialization block called');
}
}
But does anyone knows what are the real differences between these two approaches?