第63天:json的两种声明方式

一、 json

两种声明方式

 1、 对象声明   var  json = {100,height:100}

 2、 数组声明   var  man = [        //  数组的 json  
    {
        name:"刘德华",
        age : 16,
        address: "香港"
    },
    {
        name:"张学友",
        age: 33,
        address: "澳门"
    },
    {
        name:"黎明",
        age: 55,
        address: "大陆"
    }
];

for(var i=0;i<man.length;i++)
{
    console.log(man[i].name);  
}

  二、 旋转原理:

      每次点击 按钮, 他们的json 数值就更换就可以了.

      删除和添加 数组  

      pop()  删除最后一个

      shift()  删除第一个

      push() 追加 添加到最后面

      unshift()  添加到 第一个位置  

  最后一个json 删除   并且把最后一个添加到json 第一个位置

      json.unshift(json.pop());  

     json.pop()  删除最后一个元素

    console.log(json.pop())  返回最后一个值

原文地址:https://www.cnblogs.com/le220/p/7726354.html