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);
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();