How to convert instance of any type to string?
String(null)
returns - "null"
String(undefined)
returns - "undefined"
String(10)
returns - "10"
String(1.3)
returns - "1.3"
String(true)
returns - "true"
I think this is a more elegent way.
value = value+"";
If targeting ES6 or later, you could use a template literal:
function (arg) {
return `${arg}`;
}
I'm not sure you even need a function, but this would be the shortest way:
function( arg ) {
return arg + '';
}
Otherwise this is the shortest way:
arg += '';