My problem:
var Person = makeClass( // Make a class with 2 instance methods which are initialize and say
{
initialize: function(name) {
this.name = name;
},
say: function(message) {
return this.name + " says: " + message;
}
}
);
In the documentation of the @lends tag of jsdoc, I found out they are using a helper function, which they say it can take an object literal and create a class from that object's members. In the example above, the makeClass function creates a Person class, that have 2 instance methods (or they also can be static methods) which are initialize and say. I wonder how did we can create that kind of function.
What i want to know:
I tried to recreate that kind of function, but it was really hard to me, I don't know is there any way to do it. So hopefully you guys can give me a way of recreate this makeClass function.
I also want to know if this kind of creating class way is strange or not, or you can think the kind of function like makeClass is useful or not.
The reason of why do I want to create that function:
If you ask me about the reason, well I want to know the "ingredients" inside of that of function in order to understand the @lends tag of JSDoc, I want to really understand the use cases of this @lends tag in JSDoc. But facing this kind of weird way of creating class (its strange to me, I always use ES6 class before) it really hard to me to understand the @lends tag.