Friday, June 1, 2012 Tuesday, May 29, 2012 Friday, May 18, 2012 Tuesday, May 15, 2012
整體來說,很明顯地不管什麼時候,當我們會在意如何去塑造自己留給別人的印象之下,我們反而更無法冷靜地思考。以男性為例,只要想像能跟女性發生互動就可以讓他們的大腦變得有點遲鈍。 【認知科學】為什麼跟女生互動會讓男生的認知能力降低? « CASE PRESS
Facebook承认了这样一种趋势:即Facebook每个用户为其带来的收入在减少,而这一趋势在Facebook最近的季度财报中也可见一二。为什么会有这种情况?实际是因为Facebook的移动端用户增长迅猛。但是,Facebook在移动端的生财能力又远不及传统的电脑桌面端。所以,算下来每个用户的价值就被稀释了 恐慌:Facebook和Google消化不了“移动”,但又必须消化 | 36氪
Monday, May 14, 2012 Saturday, May 12, 2012 Friday, May 11, 2012 Thursday, May 10, 2012
【名稱】:艱苦卓絕
【拼音】:jiān kǔ zhuó jué
【釋義】:堅忍刻苦的精神超過尋常。
【出處】:《宋史·邵雍傳》:“始為學,即堅苦刻厲,寒不爐,暑不扇,夜不席者數年。”
【例子】:用儒家之道德,故艱苦卓厲者絕無,而冒沒奔競者皆是。(章炳麟《諸子學略說》)
加油加油!!!

(Source: tw.18dao.net)

Friday, May 4, 2012 Wednesday, May 2, 2012

Avoid ReferenceError in Javascript

As mentioned in the previous post, a reference comprises two parts: base value and reference name, for example: in the reference “window.console”, “window” is the base value and “console” is the reference name. The ReferenceError is raised when the base value of a reference could not been resolved. The easiest way to check variables is using typeof:

if(typeof undefinedVar === ‘undefined’) {}

It works across all situations without raising ReferenceError, but writing this kind of checks is really tedious.

So, how can we avoid ReferenceError without typing “typeof …” all the time?

To sum it up, just check global object properties like below no matter where the code is (global scope or function scope):

if(window.console) {

    // do something with console object

}

Any other variables such as function arguments or local variables in the function scopes, check them like this:

(function(window, undefined){

    var foo = aFunctionMayReturnUndefined();

    if(foo) {

        //do something with foo

    }

    if(window.console) {

    }

})(window)

The only requirement of this defined checking is declaring local variables in your function correctly.

Tuesday, May 1, 2012
第一個寫法會出現 ReferenceError 的原因,是因為 javascript 無法找到 gy 屬性的 base value。但如果直接指名 base value 為 window,即使 window 物件沒有 gy 屬性,還是不會出現 ReferenceError。
詳細請參考這篇:http://javascriptweblog.wordpress.com/2010/08/16/understanding-undefined-and-preventing-referenceerrors/

第一個寫法會出現 ReferenceError 的原因,是因為 javascript 無法找到 gy 屬性的 base value。但如果直接指名 base value 為 window,即使 window 物件沒有 gy 屬性,還是不會出現 ReferenceError。

詳細請參考這篇:http://javascriptweblog.wordpress.com/2010/08/16/understanding-undefined-and-preventing-referenceerrors/

Wednesday, April 25, 2012