Ray's playground

 

随笔分类 -  JavaScript

Variables, Scope, and Memory(Chapter 4 of Professional JavaScript® for Web Developers 2nd Edition)
摘要:JavaScript ’ s lack of block - level scopes is a common source of confusion.[代码]  When a variable is declared using var , it is automatically added to the most immediate contextavailable. In a function, the most immediate one is the function ’ s local context; in a with statement, themost immediate 阅读全文

posted @ 2011-01-10 19:55 Ray Z 阅读(196) 评论(0) 推荐(0)

Language Basics(Chapter 3 of Professional JavaScript® for Web Developers 2nd Edition)
摘要:The end result was forECMAScript to provide two sets of operators: equal and not equal to perform conversion beforecomparison, and identically equal and not identically equal to perform comparison without conversion.equalityCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.C 阅读全文

posted @ 2011-01-10 18:55 Ray Z 阅读(201) 评论(0) 推荐(0)

JavaScript in HTML(Chapter 2 of Professional JavaScript® for Web Developers 2nd Edition)
摘要:For pages that require a lot ofJavaScript code, this can cause a noticeable delay in page rendering, during which time the browser willbe completely blank. For this reason, modern web applications typically include all JavaScript referencesin the body element, after the page content.  HTML 4.01 de 阅读全文

posted @ 2011-01-08 13:04 Ray Z 阅读(214) 评论(0) 推荐(0)

What Is JavaScript?(Chapter 1 of Professional JavaScript® for Web Developers 2nd Edition)
摘要: 阅读全文

posted @ 2011-01-08 12:29 Ray Z 阅读(187) 评论(0) 推荐(0)

Bad Parts(Appendix B. of JavaScript: The Good Parts)
摘要:1. ==  JavaScript has two sets of equality operators: === and !==, and their evil twins == and !=. The good ones work the way you would expect. If the two operands are of the same type and have the sa... 阅读全文

posted @ 2010-07-15 22:08 Ray Z 阅读(254) 评论(0) 推荐(0)

Awful Parts(Appendix A. of JavaScript: The Good Parts)
摘要:1. Global Variables  There are three ways to define global variables. The first is to place a var statement outside of any function:  The second is to add a property directly to the global object. The... 阅读全文

posted @ 2010-07-14 22:36 Ray Z 阅读(270) 评论(0) 推荐(0)

Style(Chapter 9 of JavaScript: The Good Parts)
摘要:I want to avoid idioms that look like mistakes.  I never allow switch cases to fall through to the next case. I once found a bug in my code caused by an unintended fall through immediately after havin... 阅读全文

posted @ 2010-07-14 12:51 Ray Z 阅读(233) 评论(0) 推荐(0)

Methods(Chapter 8 of JavaScript: The Good Parts)
摘要:JavaScript includes a small set of standard methods that are available on thestandard types.  array.concat(item...)[代码]2varb=['x','y','z'];3varc=a.concat(b,true);  array.join(separator)[代码]2a.push('d'... 阅读全文

posted @ 2010-07-13 23:02 Ray Z 阅读(192) 评论(0) 推荐(0)

Regular Expressions(Chapter 7 of JavaScript: The Good Parts)
摘要:A regular expressionis the specification of the syntax of a simple language. Regular expressions are used with methods to search, replace, and extract information from strings. The methods that work w... 阅读全文

posted @ 2010-07-12 20:48 Ray Z 阅读(199) 评论(0) 推荐(0)

Arrays(Chapter 6 of JavaScript: The Good Parts)
摘要:codeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--1varis_array=function(value){2returnvalue&&3typeofvalue==='object'&&4typeofvalue.l... 阅读全文

posted @ 2010-07-11 20:19 Ray Z 阅读(170) 评论(0) 推荐(0)

Inheritance(Chapter 5 of JavaScript: The Good Parts)
摘要:codeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--1varMammal=function(name){2this.name=name;3};45Mammal.prototype.get_name=function(){6returnthis.na... 阅读全文

posted @ 2010-07-10 11:46 Ray Z 阅读(180) 评论(0) 推荐(0)

Functions part2(Chapter 4 of JavaScript: The Good Parts)
摘要:ModuleCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--1varserial_maker=function(){2varprefix='';3varseq=0;45return{6set_prefix:function(p){7prefix=Str... 阅读全文

posted @ 2010-07-09 22:42 Ray Z 阅读(190) 评论(0) 推荐(0)

Functions part1(Chapter 4 of JavaScript: The Good Parts)
摘要:There are four patterns of invocation in JavaScript: the method invocation pattern, the function invocation pattern, the constructor invocation pattern, and the apply invocation pattern. The patterns ... 阅读全文

posted @ 2010-07-08 22:40 Ray Z 阅读(328) 评论(0) 推荐(0)

Objects(Chapter 3 of JavaScript: The Good Parts)
摘要:The undefined value is produced if an attempt is made to retrieve a nonexistent member:  Attempting to retrieve values from undefined will throw a TypeError exception. This can be guarded against with... 阅读全文

posted @ 2010-07-08 12:47 Ray Z 阅读(216) 评论(0) 推荐(0)

Grammar(Chapter 2 of JavaScript: The Good Parts)
摘要:JavaScript has a single number type. Internally, it is represented as 64-bit floating point, the same as Java's double.  A block is a set of statements wrapped in curly braces. Unlike many other langu... 阅读全文

posted @ 2010-07-07 22:01 Ray Z 阅读(158) 评论(0) 推荐(0)

导航