您当前的位置: 首页 > 

暂无认证

  • 4浏览

    0关注

    92582博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

JS中封装性,你真的懂封装性嘛????

发布时间:2020-08-15 23:55:47 ,浏览量:4

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <script> /*function demo()
        {
            var num="局部变量1";
            let value="局部变量2";
            function test()
            {
                console.log("局部函数");
            }
            console.log(num);
            console.log(value);//记住,局部的变量与函数只能在他所在的作用域中输出,不然会错
            test();
        }
        demo();
        */ /*console.log(num);
        console.log(value);
        test();*/ function Person() { this.name="cyg"; let age=20; this.setAge=function(myAge) { if(myAge >= 0){ age = myAge; } } this.getAge = function () { return age; } this.say = function () { console.log("hello world"); } } let obj = new Person(); obj.setAge(666); console.log(obj.getAge()); </script> </body> </html> 
关注
打赏
1653961664
查看更多评论
立即登录/注册

微信扫码登录

0.0759s