思考题 1:

    1. var name = "The Window";
    2. var object = {
    3. name: "My Object",
    4. getNameFunc: function () {
    5. return function () {
    6. return this.name;
    7. };
    8. }
    9. };
    10. console.log(object.getNameFunc()())

    image.png

    思考题 2:

    1. var name = "The Window"; 
    2. var object = {  
    3. name: "My Object",
    4. getNameFunc: function () {
    5. var that = this;
    6. return function () {
    7. return that.name;
    8. };
    9. }
    10. };
    11. console.log(object.getNameFunc()())

    image.png