-
-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JavaScript怎么清空数组 #89
Comments
let sheldon = ['c','o','o','p','e','r']
//methods 1
sheldon = []
// methods 2
sheldon.length = 0
// methods 3
sheldon.splice(0, sheldon.length)
// methods 4
while(sheldon.length > 0) sheldon.pop()
// |
// methods 1 console.log(arry); console.log(arry); |
var array = [1, 2, 3];
array.length = 0; 2.splice方法 var array = [1, 2, 3];
array.splice(0,array.length);
var array = [1, 2, 3];
array = [];
var array = [1, 2, 3];
while(array.length > 0) {
array.shift();
}
var array = [1, 2, 3];
while(array.length > 0) {
array.pop();
}
var array = [1, 2, 3];
array = array.slice(array.length);
var array = [1, 2, 3];
// 7.1
array = array.filter(() => false);
// 7.2
array = array.filter(item => item !== undefined);
var array = [1, 2, 3];
array.fill(undefined); |
array.fill*()
array.fill(undefined)不可以吧
|
No description provided.
The text was updated successfully, but these errors were encountered: