Skip to content

Commit

Permalink
docs(symbol): fixed #1166 Symbol.toStringTag
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanyf committed Aug 22, 2023
1 parent e8c2d2e commit 4c06dfb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/symbol.md
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ String(obj) // 'str'

### Symbol.toStringTag

对象的`Symbol.toStringTag`属性,指向一个方法。在该对象上面调用`Object.prototype.toString`方法时,如果这个属性存在,它的返回值会出现在`toString`方法返回的字符串之中,表示对象的类型。也就是说,这个属性可以用来定制`[object Object]``[object Array]``object`后面的那个字符串。
对象的`Symbol.toStringTag`属性,返回一个字符串。在目标对象上面调用`Object.prototype.toString`方法时,如果`Symbol.toStringTag`属性存在,它的返回值会出现在`toString`方法返回的字符串之中,表示对象的类型。也就是说,这个属性可以用来定制`[object Object]``[object Array]``object`后面的那个字符串。

```javascript
// 例一
Expand Down

3 comments on commit 4c06dfb

@yinsang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

里面似乎还有一些“返回”的字眼不正确。修改如下,您看看。

若对象的`Symbol.toStringTag`属性被赋值为字符串,在目标对象上面调用`Object.prototype.toString`方法时,`Symbol.toStringTag`的值会出现在`toString`方法返回的字符串之中,表示对象的类型。也就是说,这个属性可以用来定制`[object Object]`或`[object Array]`中`object`后面的那个大写字母开头的单词。

@ruanyf
Copy link
Owner Author

@ruanyf ruanyf commented on 4c06dfb Aug 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个属性可以赋值为非字符串吗?

@yinsang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我试了可以,但是没有效果,不会影响[object Array]` 后面那个单词的展示。

Please sign in to comment.