话不多说,直接上代码
var obj = [{"name": "oyc", "number": "006"}, {"name": "yqr", "number": "007"}]; var person = {"name": "qq", "number": "001"}; function add(obj,person) { obj.push(person); console.log("Congratulations,add done!"); } function del(obj,person) { $.each(obj, function (n, value) { if (value.name == person.name) { obj.splice(n, 1);//t.remove(0); console.log(person.name+" has deleted"); } }) } function edit(obj,person) { $.each(obj, function (n, value) { if (value.name == person.name) { obj[n].name="123"; console.log(person.name+" has deleted"); } }) } function listObj(obj) { $.each(obj, function (n, value) { console.log(n + " - " + value.name,value.number); }); }