• 对象的创建


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>
    <body>
        
    </body>
    <script>
    //1, 创建对象 : 字面量创建对象
    let str = 'name'
    // let obj = {
    //     [str]:"张三",
    //     age:33,
    //     hobby:function(){
    //         console.log(333)
    //     }
    // }
    // console.log(obj)

    //2, 创建对象 构造函数
    // let obj = new Object();
    // obj.name = "张珊";
    // obj.age = 22;
    // obj.hobby = function(){
    //     console.log("like background")
    // }
    // console.log(obj)

    // 3, 属性方法放到原型上
    // Object.create();
    let obj = Object.create({
        name:"张三",
        age:40,
        hobby(){
            console.log("喜欢足球")
        }
    })


    </script>
    </html>
  • 相关阅读:
    Boys and Girls
    TVM: Expressions in Relay
    TVM: Pass Infrastructure
    计算机网络
    git tag 常用命令_02
    python3 异步并发编程
    git tag 常用命令_01
    XLA
    Harbor 企业级 Registry 服务器
    linux 中find命令忽略大小写进行查找
  • 原文地址:https://www.cnblogs.com/xxl910/p/12573365.html
Copyright © 2020-2023  润新知