bind call apply指向this和继承

2019-06-10  本文已影响0人  Chris__Liu
    function father(name, age) {
        this.name = name
        this.age = age
    }

    function child(name, age, height) {
        // father.apply(this,arguments)
        father.call(this, name, age)
        this.height = height
        return "name:" + this.name + "  age:" + this.age + "  height:" + this.height
    }



    obj.hellow = function(){
        console.log(this)
        return 'hellow boy'
    }
    function hellow(){
        console.log(this)
        return 'hellow boy1'
    }

    btn1.onclick = function () {
        console.log(hellow.bind(this))
    }
image.png
image.png
image.png
image.png
image.png
上一篇 下一篇

猜你喜欢

热点阅读