js 变量 对象 json

来源:互联网 发布:黑白网络怎么关了 编辑:程序博客网 时间:2024/06/07 10:24

参考 http://www.cnblogs.com/a546558309/p/3608194.html
参考 http://www.cnblogs.com/damonlan/archive/2012/03/13/2394787.html

有个typeof 用来判断各种数据类型,有两种写法:typeof xxx ,typeof(xxx)

JS JSON http://www.runoob.com/js/js-json.html

<script>    //定义js对象    var jsObject = {            "flag" : 0,            "msg" : null,            "object" : null    };      // 把js对象转换成JSON字符串    var jsonstr= JSON.stringify(jsObject );         //定义JSON字符串    var teststr = '{"flag" : 0,"msg" : null,"object" : null}';     //把JSON字符串转成成js对象    var testjson = JSON.parse(teststr);     //通过控制台 查看以上变量的值和类型     console.log("值" + teststr); // {"flag":0,"msg":null,"object":null}    console.log("类型" + typeof (teststr)); // string</script>
原创粉丝点击