I'm building own API to generate dynamic table in JS (I know about dataTables). I need some another functions but the scheme of work is similar.
I'm wondering how works a function e.g. data() in dataTables while toArray() is inside this function?
for example: when I want to get data I need to call dataTable().data() but if I want to get data as JS array I call dataTable().data().toArray();
I try in this case at shown below:
return {
data: {
toArray: () => {
return myArray;
}
}
}
My above code is works but how can I call a data() function that it return to me another data without call toArray() function?
I want to get this effect:
prototype
function oData() {
this.arr = Obj.HTML;
}
oData.prototype.data = () => {
return Obj.HTML;
}
oData.prototype.toArray = () => {
return Obj.data;
}
let obj = new oData();
obj.data() return array of HTML objects
obj.toArray() return array of data objects
but I want use obj.data().toArray() to get array of data objects