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/

Sunday, March 13, 2011 Tuesday, March 1, 2011 Monday, February 28, 2011

To summarize, an anti-pattern is a bad design that is worthy of documenting. Examples of anti-patterns in JavaScript are the following:

Polluting the namespace by defining a large number of variables in the global context

Passing strings rather than functions to either setTimeout or setInterval as this triggers the use of eval() internally.

Prototyping against the Object object (this is a particularly bad anti-pattern)

Using JavaScript in an inline form as this is inflexible

The use of document.write where native DOM alternatives such as document.createElement are more appropriate.

Essential JavaScript Design Patterns For Beginners
Sunday, February 6, 2011 Friday, February 4, 2011
Though it may not be clear from the example, the || operator returns the value of the first truthy operand, or, in cases where neither operand is truthy, it’ll return the last of both operands. The && operator returns the value of the first false operand, or the value of the last operand if both operands are truthy. jQuery Fundamentals