C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript String toString() MethodThe JavaScript toString() method returns a string representing the calling object. In other words, this method provides a string representation of the object and treats same as the valueof() method. Syntax
The toString() method is represented by the following syntax: object.toString() Returns
A String representing the object JavaScript String toString() Method ExampleLet's see some simple examples of toString() method. Example 1Here, we will print the value of string object. <script> var str="TheDeveloperBlog"; document.writeln(str.toString()); </script> Output: TheDeveloperBlog Example 2Let's see one more example to print the value of string object.
<script>
var str=new String("TheDeveloperBlog")
document.writeln(str.toString());
</script>
Output: TheDeveloperBlog
Next TopicJavaScript String
|