Monday, October 26, 2020

How to remove all elements from JavaScript Array ?

 In case you have an array in JavaScript and you want to remove all elements from that array , there are couple of ways by which you can remove all elements from your array. 


#1 

Arr = [];
#2 

 Arr.length = 0

#3 
 
 Arr.splice(0,Arr.length)

#4 
  
while(Arr.length > 0) {
    Arr.pop();
}





No comments:

Post a Comment

ASP.NET Core

 Certainly! Here are 10 advanced .NET Core interview questions covering various topics: 1. **ASP.NET Core Middleware Pipeline**: Explain the...