0

can someone explain num.tostring use in ctx.filltext() ?

ctx.rotate(ang);    ctx.translate(0, -radius*0.85);    ctx.rotate(-ang);    ctx.fillText(num.toString(), 0, 0);    ctx.rotate(-ang);

24th Jun 2017, 7:19 AM
Deepak Bisht
Deepak Bisht - avatar
1 Answer
+ 3
toString() is a method of any object in JS, which return a string value, commonly the object name textual represenation, and for basic type the string equivalent value of object (for a Number, it will 'cast' the value to the string decimal representation of the value stored in the object). This is also the method implicitly called to cast any value/object when doing implicit concatenation to string: var result = 42; var myString = "The result is: " + result; ... is internally done as: var result = 42; var myString = "The result is: " + result.toString();
24th Jun 2017, 7:35 AM
visph
visph - avatar