• JS 对象


     1 <!DOCTYPE html>
     2 <html>
     3     <head>
     4         <meta charset="UTF-8">
     5         <title></title>
     6     </head>
     7     <body>
     8         
     9     </body>
    10     
    11     <script type="text/javascript">
    12         // js 里面任何事物都可以称为一个对象
    13 //        var num1 = 5; // num1是一个数字对象
    14 //        var num2 = new Number(5);
    15         // 字符串对象
    16         var string1 = "hehe";
    17         var string2 = new String("hehe");
    18         
    19 
    20 
    21         // 数组也是一个对象(简写的形式可以称为语法糖)
    22         var array1 = [];
    23         var array2 = new Array;
    24         var array3  = new Array(1,2);
    25         
    26 
    27 
    28         // 时间对象
    29         var nowDate = new Date(); // 当前时间
    30         var date = new Date("1999,10,11");
    31         
    32 
    33         
    34         // 可以自定义对象
    35         var  obj1 = new Object;
    36         obj1.name = "gxm";
    37         obj1.age = 25;
    38         console.log(obj1);
    39         
    40         
    41 
    42         /*{name:"gxm",age:25}; 在其他语言叫 “字典”*/ 
    43         var obj2 = {name:"gxm",age:25};
    44         var student1 = {name:"gxm1",age:25,score:100,sex:"m"};
    45         var student2 = {name:"gxm2",age:25,score:100,sex:"m"};
    46         var student3 = {name:"gxm3",age:25,score:100,sex:"m"};
    47         var student4 = {name:"gxm4",age:25,score:100,sex:"m"};
    48         var student5 = {name:"gxm5",age:25,score:100,sex:"m"};
    49         var student6 = {name:"gxm6",age:25,score:100,sex:"m"};
    50         var name = ["gxm1","gxm2","gxm3","gxm4","gxm5","gxm6"];
    51     </script>
    52 </html>
  • 相关阅读:
    Solidity notes
    Solidity by Example详解
    基本命令中部
    基本命令上部
    服务器介绍
    Linux发展史及安装
    ERROR: Unrecognized command line argument: 'use'
    RequireJs 深入理解
    Redis 安装教程 (Windows 2.6.13 稳定版)
    System.AccessViolationException: 尝试读取或写入受保护的内存 解决办法
  • 原文地址:https://www.cnblogs.com/PowellZhao/p/5627466.html
Copyright © 2020-2023  润新知