js清空数组的正确做法
Emptying an array is a common JavaScript task but too often I see the task performed in the incorrect way. Many times developers will create a new array:
myArray = []; // bad
That isn’t the optimal way to get a fresh array; to truncate an array, and thus empty it, you should set the length property to zero:(正确的做法)
myArray.length = 0; // good!
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇: PHP中数组转JSon和JSon转数组的实现
- 下一篇: PHP构造JSon数据的两种方法