दूर एक विशेष तत्व सरणी से
var colors = ["red","blue","car","green"];
var carIndex = colors.indexOf("car");//get "car" index
//remove car from the colors array
colors.splice(carIndex, 1); // colors = ["red","blue","green"]
सरणी से एक विशेष तत्व निकालें
var colors = ["red","blue","car","green"];
var carIndex = colors.indexOf("car");//get "car" index
//remove car from the colors array
colors.splice(carIndex, 1); // colors = ["red","blue","green"]
जेएस से निकालें सरणी द्वारा मूल्य
const index = array.indexOf(item);
if (index !== -1) array.splice(index, 1);
जेएस मूल्य से सरणी से निकालें
const index = array.indexOf(item);
if (index !== -1) array.splice(index, 1);
मैं सरणी से एक विशिष्ट आइटम कैसे निकाल सकता हूं
const array = [2, 5, 9];
console.log(array);
const index = array.indexOf(5);
if (index > -1) {
array.splice(index, 1);
}
// array = [2, 9]
console.log(array);
जे एस सरणी हटा विशिष्ट तत्व
var ar = [1, 2, 3, 4, 5, 6];
ar.length = 4; // set length to remove elements
console.log( ar ); // [1, 2, 3, 4]
कैसे मैं दूर कर सकते हैं एक विशिष्ट आइटम की एक सरणी से
const items = ['a', 'b', 'c', 'd', 'e', 'f']
const i = 2
const filteredItems = items.slice(0, i).concat(items.slice(i + 1, items.length))
// ["a", "b", "d", "e", "f"]