1.向数组中添加json数据
var arr=[]; var json = {"name":"apple","color":"red"} arr.push(json) console.log(arr)
返回结果:
2.新增 json 键值对
var fruit =[{"name":"banana"}]; fruit[0].color='yellow' console.log(fruit)
返回结果:
var arr=[]; var json = {"name":"apple","color":"red"} arr.push(json) console.log(arr)
返回结果:
var fruit =[{"name":"banana"}]; fruit[0].color='yellow' console.log(fruit)
返回结果:
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。