When casting type to string, JavaScript simply calls the toString() method.
The type cast can produce a string for a null or undefined value without error.
var s1 = String(null); //"null" var oNull = null; var s2 = oNull.toString(); //won't work, causes an error