Given an array elements and the task is to remove the specific value element from the array with the help of JQuery. There are two approaches that are discussed below:
Approach 1: We can use the not() method which removes the element that we want. Later, use get() method to get the rest of the elements from the array.
-
Example:
<!DOCTYPE HTML>
<
html
>
Â
Â<
head
>
   Â
<
title
>
       Â
Remove certain property for all objects
       Â
in array with JavaScript.
   Â
</
title
>
Â
ÂÂ Â Â Â
<
script
src
=
   Â
</
script
>
</
head
>
Â
Â<
body
style
=
"text-align:center;"
>
Â
ÂÂ Â Â Â
<
h1
style
=
"color: green"
>
       Â
GeeksForGeeks
   Â
</
h1
>
Â
ÂÂ Â Â Â
<
p
id
=
"GFG_UP"
></
p
>
Â
ÂÂ Â Â Â
<
button
onclick
=
"gfg_Run()"
>
       Â
Click Here
   Â
</
button
>
Â
ÂÂ Â Â Â
<
p
id
=
"GFG_DOWN"
style
=
"color:green;"
></
p
>
Â
ÂÂ Â Â Â
<
script
>
       Â
var el_up = document.getElementById("GFG_UP");
       Â
var el_down = document.getElementById("GFG_DOWN");
       Â
var arr = ["GFG", "GeeksForGeeks", "Geek", "Geeks"];
       Â
var remEl = "Geek";
       Â
el_up.innerHTML = "Click on the button to perform "
               Â
+ "the operation.<
br
>Array - [" + arr + "]";
                Â
ÂÂ Â Â Â Â Â Â Â
function gfg_Run() {
           Â
var arr2 = $(arr).not([remEl]).get();
           Â
el_down.innerHTML = "[" + arr2 + "]";
       Â
}Â
   Â
</
script
>
</
body
>
Â
Â</
html
>
-
Output:
Approach 2: We can use the inArray() method to get the index of the element (that is to be removed) and then use slice() method to get the rest of the elements.
-
Example:
<!DOCTYPE HTML>
<
html
>
Â
Â<
head
>
   Â
<
title
>
       Â
Remove certain property for all objects
       Â
in array with JavaScript.
   Â
</
title
>
Â
ÂÂ Â Â Â
<
script
src
=
   Â
</
script
>
</
head
>
Â
Â<
body
style
=
"text-align:center;"
>
Â
ÂÂ Â Â Â
<
h1
style
=
"color: green"
>
       Â
GeeksForGeeks
   Â
</
h1
>
Â
ÂÂ Â Â Â
<
p
id
=
"GFG_UP"
></
p
>
Â
ÂÂ Â Â Â
<
button
onclick
=
"gfg_Run()"
>
       Â
Click Here
   Â
</
button
>
Â
ÂÂ Â Â Â
<
p
id
=
"GFG_DOWN"
style
=
"color:green;"
></
p
>
Â
ÂÂ Â Â Â
<
script
>
       Â
var el_up = document.getElementById("GFG_UP");
       Â
var el_down = document.getElementById("GFG_DOWN");
       Â
var arr = ["GFG", "GeeksForGeeks", "Geek", "Geeks"];
       Â
var remEl = "Geek";
       Â
el_up.innerHTML = "Click on the button to perform "
               Â
+ "the operation.<
br
>Array - [" + arr + "]";
                Â
ÂÂ Â Â Â Â Â Â Â
function gfg_Run() {
           Â
arr.splice($.inArray(remEl, arr), 1);
           Â
el_down.innerHTML = "[" + arr + "]";
       Â
}Â
   Â
</
script
>
</
body
>
Â
Â</
html
>
-
Output: