The first question

obj = { x: 5 }; obj.fn = (function () { this.x *= ++x; return function (y) { this.x *= (++x) + y; console.log(x); }}) (); var fn = obj.fn; obj.fn(6); //13 fn(4); //234 console.log(obj.x, x, window.x); / / 95 234 234Copy the code

The second question

let obj = { fn: (function () { return function () { console.log(this); ()}}}); obj.fn(); let fn = obj.fn; fn();Copy the code

The third question

var fullName = 'language'; var obj = { fullName: 'javascript', prop: { getFullName: function () { return this.fullName; }}}; console.log(obj.prop.getFullName()); var test = obj.prop.getFullName; console.log(test());Copy the code

The fourth question

var name = 'window'; var Tom = { name: "Tom", show: function () { console.log(this.name); }, wait: function () { var fun = this.show; fun(); }}; Tom.wait();Copy the code

The fifth problem

window.val = 1;
var json = {
    val: 10,
    dbl: function () {
        this.val *= 2;
    }
}
json.dbl();
var dbl = json.dbl;
dbl();
json.dbl.call(window);
alert(window.val + json.val); 
Copy the code

The sixth question

(function () {
    var val = 1;
    var json = {
        val: 10,
        dbl: function () {
            val *= 2;
        }
    };
    json.dbl();
    alert(json.val + val);
})(); 
Copy the code