25
rated 0 times
[
27]
[
2]
/ answers: 1 / hits: 71017
/ 15 Years ago, fri, may 15, 2009, 12:00:00
I'm implementing a function that receives an argument which it needs to convert to its string representation.
If a given object implements a toString()
method, then the function should use it. Otherwise, the function can rely on what the JavaScript implementation offers.
What I come up with is like this:
var convert = function (arg) {
return (new String(arg)).valueOf();
}
More From » javascript