In JavaScript, functions are objects, except that they can be called and executed, this is comparable to overloading the () operator of an object in other languages.
Can I apply this functionality to any object?
I know there isn't a property like [Symbol.call] or something comparable. If there is something comparable, I would greatly appreciate it if you could inform me of what it is.
If declaring objects and assigning properties to them is my only option that's okay, but I'd prefer if this could be done using a class, like C++ for example.
I could do something like this
function func(...) {
...
}
func.foo = x,
func.bar = y;
but it would be more preferable if I could do something more like
const func = {
[`()`]: function(...) {
...
},
foo: x,
bar: y
};