我想從我的物體中的一個屬性中刪除時間。實際上,我檢查:索引,如果時間戳是否存在於屬性值中。實際上我有此如何從javascript中刪除對象的時間?
輸入
[
{
"S": "Charge Interest Against Past Due Account",
"C": "Mon Apr 13 10:38:05 GMT 2015"
},
{
"S": "Charge Interest Against Past Due Account",
"C": "Mon Apr 13 10:35:05 GMT 2015"
}
]
輸出
[
{
"S": "Charge Interest Against Past Due Account",
"C": "Mon Apr 13 2015"
},
{
"S": "Charge Interest Against Past Due Account",
"C": "Mon Apr 13 2015"
}
]
的Javascript
var object = ary.map(function(o){
var result={}
// console.log(o)
for(i in o){
console.log(i+":"+o[i]) ;
if(o[i].indexOf(":")!=-1){
console.log("timestam present")
}
}
})
原始陣列應保持不變,並且結果應該在單獨的陣列被捕獲。
這是鏈接到小提琴。
這種方式你可以隨時更改日期格式,如果你想。 – vinayakj
爲什麼它不工作https://jsfiddle.net/7cd9o3uL/ – Shruti
你的安慰錯誤的變量。日誌變量'ary'本身,因爲它包含所需的輸出 – vinayakj