I've briefly followed a 2d game tutorial. It shows this style of object creation:
function component(width, height, color, x, y) {
this.width = width
...
this.method = function(){...}
// instantiate block using class
block = new component(30, 60, "red", 225, 225);
But I've also been told about ES6's class functionality, which I believe would do something very similar, but more inline with other language's formal object creation syntax:
class component {
constructor(width, height, color, x, y){
this.width = width
...
}
method(){
...
}
// instantiate block using class
block = new component(30, 60, "red", 225, 225);
What are the functional differences of these two approaches? Why would I use one over the other?