发表于: 2016-10-20 23:49:24

4 2320


# 1020day29


## 今日收获


* 用聚合的API接口写了一个天气查询页面

http://www.liuzihao1006.com/task/weather/weather.html

* 使用Ajax实现瀑布流案例


## 明日计划

  * 排序算法,递归算法

  * 学习面向对象


## 今日问题

* 作为第一个参数的函数将会在全局作用域中执行,因此函数内的 this 将会指向这个全局对象。看不懂。

function Foo() {

    this.value = 42;

    this.method = function() {

        // this 指向全局对象

        console.log(this.value); // 输出:undefined

    };

    setTimeout(this.method, 500);

}

new Foo();// 输出:undefined 

new Foo().method(); // 去掉setTimeout这样调用,打印42

--------------------------------------------------------

function Foo() {

    this.value = 42;

    method = function() {

        // this 指向全局对象

        console.log(this); // 输出:window

    };

    setTimeout(method(), 500);

}

new Foo();


##  具体收获


* 复习了时间对象

* 对继承、闭包的了解更深一点,但还是搞不懂那些this,指来指去的。



返回列表 返回列表
评论

    分享到