FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

modify bug · dahui4dev/JavaScript-Example@2844523 · GitHub

Commit 2844523

Browse files
committed
modify bug
1 parent b799a57 commit 2844523

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

‎article/005-reference-object-array.md‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ if(Array.isArray(value)){
119119
**注意最后两项**
120120

121121
```javascript 1.8
122-
123122
let colors = ['red', 'blue', 'green'];
124123

125124
console.log(colors.toString()) // red,blue,green
@@ -129,13 +128,12 @@ console.log(colors) // [ 'red', 'blue', 'green' ]
129128

130129
alert(colors.valueOf()); // red,blue,green
131130
alert(colors); // red,blue,green
132-
133131
```
132+
134133
调用 valueOf() 返回的还是数组。实际上,调用数组的 valueOf() 会调用数组每个值的 toString() 方法并做拼接。
135134
同样调用数组的 toLocaleString、toString,都会调用每个值的对应方法。
136135

137136
```javascript 1.8
138-
139137
let person1 = {
140138
toLocaleString: function(){
141139
return "1 => toLocaleString "
@@ -160,7 +158,6 @@ let persons = [person1, person2];
160158
alert(persons); // 1 => toString ,2 => toString
161159
alert(persons.toString()); // 1 => toString ,2 => toString
162160
alert(persons.toLocaleString()); // 1 => toLocaleString ,2 => toLocaleString
163-
164161
```
165162

166163
#### 2.5、数组栈方法

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL