Is this the correct syntax to use it in class Graphics?
Almos :) The first argument of apply and call is the this argument. It doesn't matter for Math.max because max doesn't care about knowing it's called via Math, but drawString needs to know which Graphics instance it's called on.
If you do g.drawString.apply(g,p); you should be fine
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Almos :) The first argument of
apply
andcall
is thethis
argument. It doesn't matter forMath.max
becausemax
doesn't care about knowing it's called viaMath
, butdrawString
needs to know which Graphics instance it's called on.If you do
g.drawString.apply(g,p);
you should be fine