本文實(shí)例講述了json實(shí)現(xiàn)添加、遍歷與刪除屬性的方法。分享給大家供大家參考,具體如下:
<script> var obj={"age":12,"name":"huangbiao"}; alert(obj.age); alert(obj.name); //添加屬性 obj["sex"] = "boy"; //遍歷JSON對象 for(var index in obj){ alert(index); alert(obj[index]); } //刪除JSON屬性 delete obj.age; alert(obj.age);</script>新聞熱點(diǎn)
疑難解答