AJAX Advantages and Disadvantages JavaScript

5 Best ways to empty an array in JavaScript [How To]

How to empty an array in JavaScript?

var userList =  ['anil','kumar','singh','kushinagar','up','india'];


Method 1: - userList =[];

Method 2: - userList.length=0;

Method 3: - userList.splice(0, userList.length);

Method 4: -
while (userList.length > 0) {

I am not recommended to use "method 4". You can use “method 2” and “method 3” because it is so fast.

I hope you are enjoying with this post! Please share with you friends. Thank you!!

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..

My Tech Blog - https://www.code-sample.com/
My Books - Book 1 and Book 2

www.code-sample.com/. Powered by Blogger.