Java Reference
In-Depth Information
result = Number("");
print("The empty string is converted to", result);
result = Number('Hello');
print("'Hello' is converted to", result);
// Convertes to the number 1982, ignoring leading and trailing whitespaces
result = Number(' 1982 ');
print("' 1982 ' is converted to", result);
result = Number(new Object(88));
print("new Object(88) is converted to", result);
result = Number(new Object());
print("new Object() is converted to", result);
// A very big number in a string
result = Number("10E2000");
print("10E2000 is converted to", result);
undefined is converted to NaN
10 + undefined is NaN
The empty string is converted to 0
'Hello' is converted to NaN
' 1982 ' is converted to 1982
new Object(88) is converted to 88
new Object() is converted to NaN
10E2000 is converted to Infinity
To String Conversion
Values of all types in Nashorn can be implicitly or explicitly converted to the String type.
Table 4-8 lists the types of values and their corresponding converted String values.
 
 
Search WWH ::




Custom Search