I\'m just wondering what it means to attach a number as a parameter to the toString()
method
E.g. obj.toString(10);
I googled a
It's not defined as a globally-applicable argument to toString
, it only makes sense on Number
, where it specifies the base to write in. You can use eg. n.toString(16)
to convert to hex.
The other built-in objects don't use any arguments and JavaScript will silently ignore unused arguments, so passing 16
to any other toString
method will make no difference. You can of course make your own toString
methods where optional arguments can mean anything you like.