From e40c55b02a6fea72c55a080953f145f076ae7d15 Mon Sep 17 00:00:00 2001 From: Hasan Abdullah <37593075+HasanAbdullah31@users.noreply.github.com> Date: Tue, 25 Jun 2019 16:52:06 -0400 Subject: [PATCH] feat: add article for JavaScript String.toString() (#36016) --- .../string/string-prototype-tostring/index.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/guide/english/javascript/standard-objects/string/string-prototype-tostring/index.md b/guide/english/javascript/standard-objects/string/string-prototype-tostring/index.md index f3e496ac225..07a829ec543 100644 --- a/guide/english/javascript/standard-objects/string/string-prototype-tostring/index.md +++ b/guide/english/javascript/standard-objects/string/string-prototype-tostring/index.md @@ -3,13 +3,18 @@ title: String.prototype.toString --- ## String.prototype.toString -This is a stub. Help our community expand it. +The `toString()` method returns a primitive string representing the given String object. -This quick style guide will help ensure your pull request gets accepted. +**Example** +```js +var x = new String("hi"); +console.log(x); // String {"hi"} +console.log(typeof x); // object +console.log(x.toString()); // hi +console.log(typeof x.toString()); // string +``` - +*Note*: for String objects, `toString()` and `valueOf()` return the same thing. #### More Information: - - - +- [String.prototype.toString() on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toString)