5js

对象

<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

上一篇:html_学习所有标签使用


下一篇:js禁止页面回退 禁止刷新页面