javascript 動態新增和刪除

JavaScript系列

記錄一下javascript操作object

    var datesBooking = [
      {"date": "04\/24\/2018"},
      {"date": "04\/25\/2018"}
    ];
    //取資料
    datesBooking.forEach(function(data, index) {
      console.log(data);
    });
var result = new Array();  
var inner = { pid:'1',pName:'aaa'};
result.push(inner);     //add
console.log(result[0]);   
delete(result[0]);      //delete
console.log(result);
//判斷陣列為空
if (array === undefined || array.length == 0) {
   
}

 

 

 

元哥的筆記