How to Empty an Array in JavaScript? Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report To empty an array in JavaScript, we can use the array literal. We can directly assign an empty array literal to the variable, it will automatically remove all the elements and make the array empty.1. Empty Array using Array LiteralWe can empty the array using the empty array literal syntax. Syntaxarr = [ ]; JavaScript // Given array let a = [ 10, 20, 30, 40, 50 ]; // Assign new array to make it empty a = []; // Display the updated array console.log("Updated Array: ", a) OutputUpdated Array: [] 2. Using array.length PropertyThe JavaScript array.length property is used to set or return the length of the array.Syntaxarr.length = 0; JavaScript // Given array let a = [ 10, 20, 30, 40, 50 ]; // Empty the array by setting its length to 0 a.length = 0; // Display Updated array and its length console.log("Updated Array: ", a); console.log("Length of Updated Array: ", a.length); OutputUpdated Array: [] Length of Updated Array: 0 3. Using array.splice() MethodThe JavaScript array.splice() method is used to remove elements from certain index and add new elements to the array.Syntaxarr.splice(0); It will start removing elements from 0 index and as the number of elements is not given it will remove all elements present in the array. JavaScript // Given array let a = [ 10, 20, 30, 40, 50 ]; // Remove elements using array.splice() method a.splice(0); // Display the updated array console.log("Updated Array: ", a) OutputUpdated Array: [] 4. Using array.pop() MethodThe JavaScript array.pop() method is used to remove the elements one by one from the array.Syntaxarr.pop(); JavaScript // Given array let a = [ 10, 20, 30, 40, 50 ]; // While loop to iterate while( a.length > 0){ // Remove the last element in // each iteration a.pop() } // Display the updated array console.log("Updated Array: ", a) OutputUpdated Array: [] Note: Array clearing techniques in JavaScript is essential for effective data management. Comment More infoAdvertise with us Next Article Company Preparation P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies javascript-array JavaScript-DSA JavaScript-Questions +1 More Similar Reads Interview PreparationInterview Preparation For Software DevelopersMust Coding Questions - Company-wise Must Do Coding Questions - Topic-wiseCompany-wise Practice ProblemsCompany PreparationCompetitive ProgrammingSoftware Design-PatternsCompany-wise Interview ExperienceExperienced - Interview ExperiencesInternship - Interview ExperiencesPractice @GeeksforgeeksProblem of the DayTopic-wise PracticeDifficulty Level - SchoolDifficulty Level - BasicDifficulty Level - EasyDifficulty Level - MediumDifficulty Level - HardLeaderboard !!Explore More...Data StructuresArraysLinked ListStackQueueBinary TreeBinary Search TreeHeapHashingGraphAdvance Data StructuresMatrixStringAll Data StructuresAlgorithmsAnalysis of AlgorithmsSearching AlgorithmsSorting AlgorithmsPattern SearchingGeometric AlgorithmsMathematical AlgorithmsRandomized AlgorithmsGreedy AlgorithmsDynamic ProgrammingDivide & ConquerBacktrackingBranch & BoundAll AlgorithmsProgramming LanguagesCC++JavaPythonC#Go LangSQLPHPScalaPerlKotlinWeb TechnologiesHTMLCSSJavaScriptBootstrapTailwind CSSAngularJSReactJSjQueryNodeJSPHPWeb DesignWeb BrowserFile FormatsComputer Science SubjectsOperating SystemsDBMSComputer NetworkComputer Organization & ArchitectureTOCCompiler DesignDigital Elec. & Logic DesignSoftware EngineeringEngineering MathematicsData Science & MLComplete Data Science CourseData Science TutorialMachine Learning TutorialDeep Learning TutorialNLP TutorialMachine Learning ProjectsData Analysis TutorialTutorial LibraryPython TutorialDjango TutorialPandas TutorialKivy TutorialTkinter TutorialOpenCV TutorialSelenium TutorialGATE CSGATE CS NotesGate CornerPrevious Year GATE PapersLast Minute Notes (LMNs)Important Topic For GATE CSGATE CoursePrevious Year Paper: CS exams Like