当前位置:网站首页>Typescript empty array
Typescript empty array
2022-07-23 17:25:00 【Liang Yunliang】
Mode one : Set the length attribute of the array to 0
let array = ["aa","bb","cc","dd"]
console.log(array)
array.length=0
console.log(array)
Mode two : call splice remove
splice(): Add or remove elements from an array .
let array = ["aa","bb","cc","dd"]
console.log(array)
array.splice(0,array.length)
console.log(array)
Mode three : Let the variable point to a new array
let array = ["aa","bb","cc","dd"]
console.log(array)
array = []
console.log(array)
Be careful : This method may lead to memory leakage
边栏推荐
猜你喜欢
随机推荐
程序员最想干的三件事 |漫画
Pymoo learning (1): basic concepts
Software configuration | Anaconda download, installation, environment configuration and uninstall
Repository XXX does not have a Realease file「建议收藏」
Virtual machine network connection mode
食品安全|火腿肠午餐肉,真有说的那么不堪?
本周投融报:Web3游戏熊市吸金
Fundamentals of C language -- 2-5 points of knowledge about pointers and functions
职场3道坎:年薪30万、50万、100万
Kubernetes 聚焦Kubelet职责
Nodejs implements token login registration (koa2)
Explain SQL optimization in detail
七月集训(第23天) —— 字典树
Compressed storage of arrays and special matrices
VScode——代码、文件改动无法保存
食品安全|喝鲜奶可能感染结核病?带你了解什么是牛奶灭菌
How to set up the router correctly
Opencv open camera, edge detection
Kubernetes Kubelet管理pod核心流程
Solution for iPhone unable to open openv** file







