码迷,mamicode.com
首页 > Web开发 > 详细

5js

时间:2020-07-28 22:29:44      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:bsp   nbsp   class   object   rip   pre   console   UNC   log   

对象

<script>
        var obj = {
            name: ‘zsf‘,
            sex: ‘nan‘,
            age: 33,
            sayHi:function() {
                console.log(‘Hi~~‘)
            }
        }
        console.log(obj.name)
        obj.sayHi()
    </script>
var obj2 = new object();
        obj2.name = ‘拼多多‘
        obj2.sayHi = function {
            console.log(‘Hi~~‘)
        }
function Star(uname,age,sex) {
            this.name = uname;
            this.age = age;
            this.sex = sex;
            this.sing = function(song) {
                console.log(song)
            }
        }
        var ldh = new Star(‘刘德华‘,23,‘男‘)
        console.log(typeof(ldh))
        ldh.sing(‘是理想‘)
for (var k in ldh) {
            console.log(k);
            console.log(ldh[k])
        }

 

5js

标签:bsp   nbsp   class   object   rip   pre   console   UNC   log   

原文地址:https://www.cnblogs.com/gao-chao/p/13393200.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!