zoukankan      html  css  js  c++  java
  • javacsript (十一) 对象

    他的对象的概念和python的字典的格式一样,

    JavaScript 对象

    对象由花括号分隔。在括号内部,对象的属性以名称和值对的形式 (name : value) 来定义。属性由逗号分隔:

    var person={firstname:"Bill", lastname:"Gates", id:5566};

    上面例子中的对象 (person) 有三个属性:firstname、lastname 以及 id。

    空格和折行无关紧要。声明可横跨多行:

    var person={
    firstname : "Bill",
    lastname  : "Gates",
    id        :  5566
    };
    

    对象属性有两种寻址方式:

    实例

    name=person.lastname;
    name=person["lastname"]


    <!DOCTYPE html>
    <html>
    <body>
    
    <script>
    var person={
    firstname : "Bill",
    lastname  : "Gates",
    id        :  5566
    };
    document.write(person.lastname + "<br />");
    document.write(person["lastname"] + "<br />");
    </script>
    
    </body>
    </html>


  • 相关阅读:
    Mybatis连接配置文件详解
    MyBatis映射配置文件详解
    AGC 016 C
    CodeForces
    UVA
    某5道CF水题
    DZY Loves Chinese / DZY Loves Chinese II
    [SHOI2016] 黑暗前的幻想乡
    CodeForces
    CodeForces
  • 原文地址:https://www.cnblogs.com/bokun-wang/p/3654668.html
Copyright © 2011-2022 走看看