javascript toString() method
Translation results:
英[strɪŋ] 美[strɪŋ]
n.String; rope, belt; thread, plant fiber; [Computer Science] String
vt. Winding, tuning; To line up in a line or a series; to tie, tie or hang with a thread; to extend or extend
Third person singular: strings Plural: strings Present participle: stringing Past tense: strung Past participle: strung
javascript toString() methodsyntax
How to use the toString() method?
The toString() method can convert a logical value into a string and return the result. The string "true" or "false" is returned according to the original Boolean value or the value of the booleanObject object
Function: Convert the array to a string and return the result.
Syntax: arrayObject.toString()
Return: The string representation of arrayObject. The return value is the same as the string returned by the join() method without parameters.
Note: When an array is used in a string environment, JavaScript will call this method to automatically convert the array into a string. However, in some cases, it is necessary to call this method explicitly.
Note: Elements in the array are separated by commas.
javascript toString() methodexample
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script type="text/javascript"> var arr = new Array(3) arr[0] = "George" arr[1] = "John" arr[2] = "Thomas" document.write(arr.toString()) </script> </body> </html>
Run instance »
Click the "Run instance" button to view the online instance