File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -401,7 +401,25 @@ obj.toString(obj) // "[object Object]"
401
401
obj .toLocaleString (obj) // "[object Object]"
402
402
```
403
403
404
- 这个方法的主要作用是留出一个接口,让各种不同的对象实现自己版本的` toLocaleString ` ,用来返回针对某些地域的特定的值。目前,主要有三个对象自定义了` toLocaleString ` 方法。
404
+ 这个方法的主要作用是留出一个接口,让各种不同的对象实现自己版本的` toLocaleString ` ,用来返回针对某些地域的特定的值。
405
+
406
+ ``` javascript
407
+ var person = {
408
+ toString (): function () {
409
+ return ' Henry Norman Bethune' ;
410
+ },
411
+ toLocaleString (): function () {
412
+ return ' 白求恩' ;
413
+ }
414
+ };
415
+
416
+ person .toString () // Henry Norman Bethune
417
+ person .toLocaleString () // 白求恩
418
+ ```
419
+
420
+ 上面代码中,` toString() ` 方法返回对象的一般字符串形式,` toLocaleString() ` 方法返回本地的字符串形式。
421
+
422
+ 目前,主要有三个对象自定义了` toLocaleString ` 方法。
405
423
406
424
- Array.prototype.toLocaleString()
407
425
- Number.prototype.toLocaleString()
You can’t perform that action at this time.
0 commit comments