js var $this = this

581 ワード


    var user = function () {
        this.name;
    }
    user.prototype.init = function (name) {
        // $this     user
        var $this = this;
        $this.name = name;
        A();
        function A() {
            //           user.name,  user.say().        
            $this.say($this.name);
        }
    }
    user.prototype.say = function(words) {
        console.log('say : ' + words);
    }
    var tom = new user();
    tom.init('tom');


$thisの中の$は記号が完全にAthis,Bthisに置き換えることができるだけで、JQの中の$とは関係ありません.