what is the point of assign classes and functions to variables? I mean in other languages like Java, functions are functions and classes are classes ,to get what I mean fully check out the code below
const creature=class Animal {
constructor(name) {
this.name = name;
}
}
const cat = new creature('Lilly');
console.log(cat.name); // Lilly
const dog = new Animal('Boby');
console.log(dog.name); //Error
const sum=(x,y)=>x+y;
console.log(sum(1,2));//3
function sum2(x,y) {
return x+y;
}
console.log(sum2(2,1));//3
I feel it’s confusing to demonstrate between a function and a variable with more complex and sophisticated code