Filter by Tags

How to remove an element from an array in JavaScript ?



0 0

How can I remove an element from an array in javascript ?

Open E-School
Posted on : Fri, Jan 19, 2018
Views : 106

Ask Question

If you want to ask question you must LogIn or SignUp
Login SignUp

Answers (1)


Javascript does not provide any direct method to remove an element from the array. If you wish to remove an element you have to first find the index of the element in the array and then use the splice function to remove that element from the array

var array = [1,2,3,4,5];

var indexOfElementToRemove = array.indexOf(4);

if(indexOfElementToRemove > -1)
array.splice(indexOfElementToRemove, 1);

This tutorial explains this concepts in more details 

Ravinder Singh
Fri, Jan 19, 2018

Edit Answer

This answer will permanently deleted. Do you really want to delete this Answer ?
To Add your Answer Please
LogIn | SignUp

Quick Links



Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..


Login to Open ESchool OR Create your account    Login   SignUp