如何正确使用Array.Splice?
var myEmptyData = [];
myEmptyData = $.parseJSON('[{
"m_sPartNumber": "B104-92",
"m_sJobStep": "0300",
"m_sQTY": "170.000",
"m_sRunHrs": "0.1400",
"m_sRunPriority": "20150403 MAFC8X0114229",
"m_sMO": "MU43380",
"m_sAssemblyMO": "MAFC8X0",
"m_sDesc": "B104-92 TP DWR FRT",
"m_sTagID": "",
"m_sWorkCenter": "AL018",
"isWandOn": "N"
}, {
"m_sPartNumber": "B228-53",
"m_sJobStep": "0300",
"m_sQTY": "21.000",
"m_sRunHrs": "0.0441",
"m_sRunPriority": "20150403 MAFDCL0190143",
"m_sMO": "M085780",
"m_sAssemblyMO": "MAFDCL0",
"m_sDesc": "B228-53 VAL",
"m_sTagID": "",
"m_sWorkCenter": "AL028",
"isWandOn": "N"
}, {
"m_sPartNumber": "B175-93",
"m_sJobStep": "0300",
"m_sQTY": "228.000",
"m_sRunHrs": "0.7296",
"m_sRunPriority": "20150406 MAFDC60132094",
"m_sMO": "M947070",
"m_sAssemblyMO": "MAFDC60",
"m_sDesc": "B175-93 LF SD",
"m_sTagID": "",
"m_sWorkCenter": "AL004",
"isWandOn": "N"
}, {
"m_sPartNumber": "B131-85",
"m_sJobStep": "0300",
"m_sQTY": "150.000",
"m_sRunHrs": "0.4500",
"m_sRunPriority": "20150406 MAFDDJ0162969",
"m_sMO": "M964230",
"m_sAssemblyMO": "MAFDDJ0",
"m_sDesc": "B131-85 LF MTR LEG",
"m_sTagID": "",
"m_sWorkCenter": "AL014",
"isWandOn": "N"
}, {
"m_sPartNumber": "B175-93",
"m_sJobStep": "0300",
"m_sQTY": "228.000",
"m_sRunHrs": "0.7296",
"m_sRunPriority": "20150406 MAFDC60132097",
"m_sMO": "M947130",
"m_sAssemblyMO": "MAFDC60",
"m_sDesc": "B175-93 RT SD",
"m_sTagID": "",
"m_sWorkCenter": "AL004",
"isWandOn": "N"
}]');
var myEmptyDataNew = myEmptyData.splice(4, 1);
答案 0 :(得分:1)
splice
正常工作(内联于数组)。
splice
返回已删除的项目。
myEmptyData.splice(4, 1);
console.log(myEmptyData);
splice()方法通过删除现有元素和/或添加新元素来更改数组的内容。
文档:https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/splice