Using JQuery Array

10:12 AM | , , , , , , , , ,

1. Array Push

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi")

The result of fruits will be:
Banana,Orange,Apple,Mango,Kiwi

2. Remove Array Elemen

var y = [1, 2, 3];
var removeItem = 2;

y = jQuery.grep(y, function(value) {
  return value != removeItem;
});
or
var y = [1, 2, 3];
var removeItem = 2;
y.splice( $.inArray(removeItem, y), 1 );
or
var y = [1, 2, 3];
y.remove(2);
The result of fruits will be:
1,3


0 comments:

Post a Comment

Please leave a comment