I found the following way of calling prototype methods in javascript :
this.abc(x,y,z).cnt;
What will this statement call, the arguments and what will be the return values. I saw this kind of usage in my application that Im currently working on.
this.abc(x,y,z).cnt means
.abc is a method of your current object (or whatever this is defined to be).abc accepts x, y, z and returns an objectcntthis.abc(x,y,z).cnt basically gets the value of that propertyIf you are familiar with languages like Python, it is equivalent to
self.abc(x, y, z)["cnt"]
That this call method abc with parameter x,y,z and then take cnt property.
Look at this example, and focus to variable data in abc method.
// init a class
function Obj(){}
// add method abc
Obj.prototype.abc = function(x, y, z) {
var cnt = x + y + z;
var data = {cnt: cnt};
// return object with cnt property
return data;
}
const obj = new Obj();
const x = 1, y = 2, z = 3;
// cnt = 6
var cnt = obj.abc(x,y,z).cnt;
// equal with this
var data = obj.abc(x, y, z);
console.log(data.cnt)