Casting a custom object to another custom object in Javascript -
Casting a custom object to another custom object in Javascript -
is possible cast custom object custom object in javascript? example, in java implementation of code trying convert javascript, have done following:
return ((timeseriespoint)tsarray.get(pointindex)).get(valueindex); where tsarray arraylist , timeseriespoint custom class implementation exists. possible perform such casting timeseriespoint in javascript?
thanks in advance
there no types objects in javascript, there no casting.
for want do, timeseriespoint constructor should take 1 point argument , build new object it, can invoke like
return (new timeseriespoint(tsarray.get(pointindex)).get(valueindex); alternatively, if points in array similar timeseries-points (and qualify them via duck typing, i.e. have same instance properties), apply timeseriespoint get method on them:
return timeseriespoint.prototype.get.call(tsarray.get(pointindex), valueindex); javascript casting
Comments
Post a Comment