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

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -