zoukankan      html  css  js  c++  java
  • javascript疑难问题---14、js的字面量对象和JSON的区别

    javascript疑难问题---14、js的字面量对象和JSON的区别

    一、总结

    一句话总结:

    json键值对中的键都要带上双引号
    json键值对中的值只支持四种基本类型:数值、字符串、bool值、null,不支持函数和undefined

    二、js的字面量对象和JSON的区别

    博客对应课程的视频位置:14、js的字面量对象和JSON的区别
    https://www.fanrenyi.com/video/4/183

     1 <!DOCTYPE html>
     2 <html lang="en">
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>js的字面量对象和JSON的区别</title>
     6 </head>
     7 <body>
     8 <!--
     9 
    10 json 键值对中的键 都要带上双引号
    11 json 键值对中的值 只支持四种基本类型:数值,字符串,bool值,null
    12 不支持函数和undefined
    13 
    14 -->
    15 <script>
    16     var zhuBaJie={
    17         name:'猪八戒',
    18         age:3,
    19         say:function () {
    20             console.log(this.name+' '+this.age);
    21         }
    22     };
    23     console.log(zhuBaJie);
    24     zhuBaJie.say();
    25 
    26     console.log(JSON.stringify(zhuBaJie));
    27     console.log(JSON.parse(JSON.stringify(zhuBaJie)));
    28 </script>
    29 </body>
    30 </html>

     
  • 相关阅读:
    Labeling Balls
    Following Orders
    Frame Stacking
    Window Pains
    Sort it all out
    Ferry Loading||
    今年暑假不AC
    xcode10 出现 框架 或者 pod 出错
    网络请求 步骤
    swift UIAlertController使用 UIAlertController的宽度 为270
  • 原文地址:https://www.cnblogs.com/Renyi-Fan/p/12595728.html
Copyright © 2011-2022 走看看