Commit 0970124 1 parent ddb7a2f commit 0970124 Copy full SHA for 0970124
File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -107,16 +107,22 @@ console.log(x.length);
107
107
----
108
108
instance.length : Number
109
109
110
- The number of items in **this**. It is 1 greater
111
- than the index of the last item.
110
+ The number of items in **this**. It is 1 greater than the index of the last item.
111
+ Setting **length** to a smaller number than the current **length** will remove
112
+ elements from the end of the list.
112
113
113
114
<example>
114
115
console.log([].length);
115
116
console.log(['a', 'b', 'c'].length);
116
117
console.log(Array(100).length);
118
+
117
119
var x = [];
120
+ // Assigning to an index automatically adjusts length
118
121
x[50] = 'foo';
119
122
console.log(x.length);
123
+
124
+ // Set length to 0 to clear the list.
125
+ x.length = 0;
120
126
</example>
121
127
122
128
Spec:
You can’t perform that action at this time.
0 commit comments