您的位置:首页 > Web前端 > JavaScript

js对json增删改查操作

2011-03-08 14:09 357 查看
<script type="text/javascript">
Array.prototype.clear = function() {
this.length = 0;
}
Array.prototype.insertAt = function(index, obj) {
this.splice(index, 0, obj);
}
Array.prototype.remove = function(index) {
this.splice(index, 1);
}

var t = [{ 'a': {'c':22}, 'b': 2 }, { 'a': 2}];
t.push({ 'a': 3 }); //增
//t[0].a = 11; //改
//t.remove(0); //删
alert(t[0].a.c);
</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: