I'm trying to include an object of function as a static class properties, to call like myClass.setPayload[id].call(this, buffer).
Actually, i have this :
var setPayload = {
0x01: function(buffer){...},
0x0a: function (buffer) {...}
}
class myClass{
constructor(buffer){
...
setPayload[buffer[1]].call(this, buffer.slice(...))
}
}
The objective is to suppress the nedd of constructor, so i try the following, that not work :
class myClass{
static setPayload = {
0x01: function(buffer){...},
0x0a: function(buffer){...}
}
}
Suggestions ?
Static is only used to define a method for a class - see static - JavaScript You can either set: