/**
@param [items] 向陣列末尾新增的新專案
@return 返回把指定的值新增到陣列後的新長度
*/array.prototype.push = function(items) {};
ps:push()方法會直接對原始陣列進行操作,會改變原始陣列。
2、pop():刪除並返回陣列的最後乙個元素。
/**
@return 返回陣列的最後乙個元素
*/array.prototype.pop = function() {};
3、splice(start, deletecount, items):對陣列進行增刪改操作。
/**
@param [start] 規定新增/刪除專案的位置;使用負數可從陣列結尾處規定位置
@param [deletecount] 要刪除的專案數量;如果設定為0,則不會刪除專案
@param [items] 可選引數,向陣列新增的新專案
@return 返回包含被刪除專案的新陣列
*/array.prototype.splice = function(start,deletecount,items) {};
ps:
1)、splice()方法會直接對原始陣列進行操作,會改變原始陣列;
2)、splice()方法可刪除從start處開始的零個或多個元素,並且用引數列表items中宣告的乙個或多個值來替換那些被刪除的元素,即為改;
3)、如果從陣列中刪除了元素,則返回的是含有被刪除的元素的陣列。
var testarr = [1, 2, 3]
// 增:push
testarr.push(4) // [1, 2, 3, 4]
// 增:splice
testarr.splice(1, 0, 5) // [1, 5, 2, 3, 4]
// 刪:pop
testarr.pop() // [1, 5, 2, 3]
// 刪:splice
testarr.splice(1, 1) // [1, 2, 3]
// 改:splice
testarr.splice(1, 1, 99) // [1, 99, 3]
參考: 在LINQ中對資料進行增 刪 改操作
fairceodataclassesdatacontext f new fairceodataclassesdatacontext 新增 product product new product product.productname txtproductname.text.trim product....
MySQL中對資料進行增刪改查
新增資料 insert into table name field1,field2,fieldn values value1,value2,valuen 如果要新增多條資料的話一定,乙個括號代表 一條,不要把多條資料寫在乙個括號裡。insert into table name field1,fiel...
JS陣列操作之增刪改查
js提供了很多方便運算元組的方法,本文所要分享的就是如何快速對陣列進行增 刪 改 查。1 push 可接收任意數量的引數,把它們逐個新增至陣列末尾,並返回修改後陣列的長度。例如 var arr var len arr.push 1 console.log arr 1 console.log len ...