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