To simplify, let me give you an example.
Suppose I have a class name defined as Point which simply initializes X and Y axis coordinates. Therefore, the call that I was looking to satisfy was :-
The function getPoints simply prints out the value of the x and y.
Lets start building the class.
There we are. We have the class built and it simply initializes the object via this.
Now we need to implement the feature that says, if the passed arguments are of type Object, add their x and y points and pass it to the class variables. So getPoints can print those points. Now this is my approach and this may not be the best, but it worked for me.
I simply checked if the type of the arguments passed is object type or not. If it is of type object, handle differently and pass on the value.
So if I put the following in the console -
var p = new Point(new Point(10,13), new Point(12,14)); p.getPoints(); var q = new Point(12,23); q.getPoints();
The Output is -
22 27 12 23
Any suggestions are most welcome. Again. this may not be the best approach but It worked for me. Do comment.