For example, the Javascript variable formats (string, array, function, date, number, boolen) tostring () can be used as a reference for output results.
Example 1 Number
VaR num1 = 10;
Document. Write (num1.tostring (2); // output 1010
Document. Write (num1.tostring (8); // OUTPUT 12
Document. Write (num1.tostring (16); // output
Example 2 array
VaR arr = new array (1, 2, 3 );
Document. Write (ARR. tostring () // 1, 2, 3
Example 3 string
VaR arr = "true"
Document. Write (ARR. tostring () // true
VaR arr = 4
Document. Write (ARR. tostring () // 4
Example 4 boolen
VaR arr = new Boolean (5)
Document. Write (ARR. tostring () // true
VaR arr = new Boolean (0)
Document. Write (ARR. tostring () // false
Example 5 time object
VaR arr = new date ();
Document. Write (ARR. tostring () // wed Oct 01 2014 13:29:40 GMT + 0800 (China Standard Time)
Document. Write (ARR. tolocalestring () // October 1, 2014 1:30:33
Example 6 Function
Function add (a, B ){
VaR A, B, C;
C = A + B;
Return C;
}
Document. Write (Add. tostring (); // function add (a, B) {var A, B, C; C = a + B; return C ;}
Tostring () method