js method to clear the array

let list = [1, 2, 3]

list.splice(0, list.length); // 方法一

// list.length = 0; // 方法二

console.log(list); // []

 

 

Guess you like

Origin blog.csdn.net/qq_40015157/article/details/113869025