- 浏览: 11068 次
最新评论
javascript使用全集2
2011年04月08日
3.3 写出字符串
document.write("");
3.2 document.from
指定 表单域
3.1 document.all.id
查找指定 HTML 页面 ID 或 名字
3. document
2.2 转到特定网页
onClick="location.href=' http://127.0.0.1/'"
2.1 单独 location
取页面地址
2. location
1.4 this.height
取高度属性
1.3 this.width
取宽度属性
1.2 this.href
取链接地址
1.1 this.src
取图片地址
1. this
---/---------------------------------------------- -----------
问题集:
3. return 返回多个值 2006-10-14 14:13:18
2. 理解 setInternal 用法
1. 理解 void 用法
---/---------------------------------------------- -----------
相关摘要:
24. Keep in mind that the function statement is available in all versions of JavaScript, the Function( ) constructor is available only in JavaScript 1.1 and later, and function literals are available only in JavaScript 1.2 and later. Recall that we said the three functions defined earlier are "more or less" equivalent -- there are some differences between these three techniques for function definition, which we'll consider in Section 11.5.
//JavaScript: The Definitive Guide, 4th Edition -- 7.1.3 Function Literals
2006-10-19 14:35:56
23. The Function( ) constructor expects any number of string arguments. The last argument is the body of the function -- it can contain arbitrary JavaScript statements, separated from each other by semicolons. All other arguments to the constructor are strings that specify the names of the parameters to the function being defined. If you are defining a function that takes no arguments, you simply pass a single string -- the function body -- to the constructor.
//JavaScript: The Definitive Guide, 4th Edition -- 7.1.2 The Function( ) Constructor
2006-10-19 14:16:18
22. Note that ECMAScript v3 does not allow function definitions to appear anywhere; they are still restricted to top-level global code and top-level function code. This means that function definitions may not appear within loops or conditionals, for example.[1] These restrictions on function definitions apply only to function declarations with the function statement. As we'll discuss later in this chapter, function literals (another feature introduced in JavaScript 1.2 and standardized by ECMAScript v3) may appear within any JavaScript e??xpression, which means that they can appear within if and other statements.
//JavaScript: The Definitive Guide, 4th Edition -- 7.1 Defining and Invoking Functions
2006-10-19 14:10:13
21. try and finally can be used together without a catch clause. In this case, the finally block is simply cleanup code that is guaranteed to be executed, regardless of any break, continue, or return statements within the try clause. For example, the following code uses a try/finally statement to ensure that a loop counter variable is incremented at the end of each iteration, even when an iteration terminates abruptly because of a continue statement:
//JavaScript: The Definitive Guide, 4th Edition -- 6.17 try/catch/finally
2006-10-18 19:18:08
20. The continue statement, in both its labeled and unlabeled forms, can be used only within the body of a while, do/while, for, or for/in loop. Using it anywhere else causes a syntax error.
//JavaScript: The Definitive Guide, 4th Edition -- 6.12 continue
2006-10-18 16:03:46
19. The following rules are used to determine whether two values are identical according to the === operator:
If the two values have different types, they are not identical.
If both values are numbers and have the same value, they are identical, unless either or both values are NaN, in which case they are not identical. The NaN value is never identical to any other value, including itself! To check whether a value is NaN, use the global isNaN( ) function.
If both values are strings and contain exactly the same characters in the same positions, they are identical. If the strings differ in length or content, they are not identical. Note that in some cases, the Unicode standard allows more than one way to encode the same string. For efficiency, however, JavaScript string comparison compares strictly on a character-by-character basis, and it assumes that all strings have been converted to a "normalized form" before they are compared. See the "String.localeCompare( )" reference page in the core reference section of this book for another way to compare strings.
If both values are the boolean value true or both are the boolean value false, they are identical.
If both values refer to the same object, array, or function, they are identical. If they refer to different objects (or arrays or functions) they are not identical, even if both objects have identical properties or both arrays have identical elements.
If both values are null or both values are undefined, they are identical.
The following rules are used to determine whether two values are equal according to the == operator:
If the two values have the same type, test them for identity. If the values are identical, they are equal; if they are not identical, they are not equal.
If the two values do not have the same type, they may still be equal. Use the following rules and type conversions to check for equality:
If one value is null and the other is undefined, they are equal.
If one value is a number and the other is a string, convert the string to a number and try the comparison again, using the converted value.
If either value is true, convert it to 1 and try the comparison again. If either value is false, convert it to 0 and try the comparison again.
If one value is an object and the other is a number or string, convert the object to a primitive and try the comparison again. An object is converted to a primitive value by either its toString( ) method or its valueOf( ) method. The built-in classes of core JavaScript attempt valueOf( ) conversion before toString( ) conversion, except for the Date class, which performs toString( ) conversion. Objects that are not part of core JavaScript may convert themselves to primitive values in an implementation-defined way.
Any other combinations of values are not equal.
As an example of testing for equality, consider the comparison:
"1" == true
This e??xpression evaluates to true, indicating that these very different-looking values are in fact equal. The boolean value true is first converted to the number 1, and the comparison is done again. Next, the string "1" is converted to the number 1. Since both numbers are now the same, the comparison returns true.
When the equality operator in JavaScript 1.1 attempted to convert a string to a number and failed, it displayed an error message noting that the string could not be converted, instead of converting the string to NaN and returning false as the result of the comparison. This bug has been fixed in JavaScript 1.2.
//JavaScript: The Definitive Guide, 4th Edition -- 5.4 Equality Operators
2006-10-16 21:56:30
18. In top-level code (i.e., JavaScript code that is not part of a function), you can use the JavaScript keyword this to refer to the global object. Within functions, this has a different use, which is described in Chapter 7.
//JavaScript: The Definitive Guide, 4th Edition -- 4.6 Variables as Properties
2006-10-16 16:08:34
17. Garbage collection is automatic and is invisible to the programmer. You can create all the garbage objects you want, and the system will clean up after you! You need to know only enough about garbage collection to trust that it works; you don't have to wonder about where all the old objects go. For those who aren't satisfied, however, Section 11.3, contains further details on the JavaScript garbage-collection process.
//JavaScript: The Definitive Guide, 4th Edition -- 4.5 Garbage Collection
2006-10-16 16:01:55
16. Primitive Types and Reference Types
var a = [1,2,3]; // Initialize a variable to refer to an array
var b = a; // Copy that reference into a new variable
a[0] = 99; // Modify the array using the original reference
alert(b); // Display the changed array [99,2,3] using the new reference
If this result does not seem surprising to you, you're already well familiar with the distinction between primitive and reference types. If it does seem surprising, take a closer look at the second line. Note that it is the reference to the array value, not the array itself, that is being assigned in this statement. After that second line of code, we still have only one array object; we just happen to have two references to it.
//JavaScript: The Definitive Guide, 4th Edition -- 4.4 Primitive Types and Reference Types
15. 在任何情况下,如果六个月以后您还能毫不费力地阅读和理解所编写的代码,则说明这些代码写得不错。
//Windows 脚本技术 -- JScript -- 什么是 JScript?
2006-10-16 14:12:55
14. The rule that all variables declared in a function are defined throughout the function can cause surprising results. The following code illustrates this:
var scope = "global";
function f( ) {
alert(scope); // Displays "undefined", not "global"
var scope = "local"; // Variable initialized here, but defined everywhere
alert(scope); // Displays "local"
}
f( );
//JavaScript: The Definitive Guide, 4th Edition -- 4.3 Variable Scope
13. Variable Scope
The scope of a variable is the region of your program in which it is defined. A global variable has global scope -- it is defined everywhere in your JavaScript code. On the other hand, variables declared within a function are defined only within the body of the function. They are local variables and have local scope. Function parameters also count as local variables and are defined only within the body of the function.
Within the body of a function, a local variable takes precedence over a global variable with the same name. If you declare a local variable or function parameter with the same name as a global variable, you effectively hide the global variable. For example, the following code prints the word "local":
var scope = "global"; // Declare a global variable
function checkscope( ) {
var scope = "local"; // Declare a local variable with the same name
document.write(scope); // Use the local variable, not the global one
}
checkscope( ); // Prints "local"
//JavaScript: The Definitive Guide, 4th Edition -- 4.3 Variable Scope
2006-10-16 1:11:59
12. In general, functions do not know what variables are defined in the global scope or what they are being used for. Thus, if a function uses a global variable instead of a local one, it runs the risk of changing a value upon which some other part of the program relies. Fortunately, avoiding this problem is simple: declare all variables with var
//JavaScript: The Definitive Guide, 4th Edition -- 4.3 Variable Scope
2006-10-15 22:23:32
11. If you attempt to read the value of an undeclared variable, JavaScript will generate an error. If you assign a value to a variable that you have not declared with var, JavaScript will implicitly declare that variable for you. Note, however, that implicitly declared variables are always created as global variables, even if they are used within the body of a function. To prevent the creation of a global variable (or the use of an existing global variable) when you meant to create a local variable for use within a single function, you must always use the var statement within function bodies. It's best to use var for all variables, whether global or local. (The distinction between local and global variables is explored in more detail in the next section.)
//JavaScript: The Definitive Guide, 4th Edition -- 4.2.1 Repeated and Omitted Declarations
2006-10-15 22:00:53
10. Error Objects
ECMAScript v3 defines a number of classes that represent errors. The JavaScript interpreter "throws" an object of one of these types when a runtime error occurs. (See the throw and try statements in Chapter 6 for a discussion of throwing and catching errors.) Each error object has a message property that contains an implementation-specific error message. The types of predefined error objects are Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, and URIError. You can find out more about these classes in the core reference section of this book.
//JavaScript: The Definitive Guide, 4th Edition -- 3.11 Error Objects
2006-10-15 19:39:08
9. undefined
Another special value used occasionally by JavaScript is the undefined value returned when you use either a variable that has been declared but never had a value assigned to it, or an object property that does not exist. Note that this special undefined value is not the same as null.
Although null and the undefined value are distinct, the == equality operator considers them to be equal to one another. Consider the following:
my.prop == null
//JavaScript: The Definitive Guide, 4th Edition -- 3.8 undefined
2006-10-15 18:02:39
8. The way to really learn a new programming language is to write programs with it.
//JavaScript: The Definitive Guide, 4th Edition -- 1.10 Exploring JavaScript
2006-10-14 2:40:02
7. Both Netscape and Microsoft have made their JavaScript interpreters available to companies and programmers who want to embed them in their applications. Netscape's interpreter was released as open source and is now available through the Mozilla organization (see http://www.mozilla.org/js/). Mozilla actually provides two different versions of the JavaScript 1.5 interpreter. One is written in C and is called "SpiderMonkey." The other is written in Java and, in a flattering reference to this book, is called "Rhino."
//JavaScript: The Definitive Guide, 4th Edition -- 1.4 JavaScript in Other Contexts
2006-10-14 1:13:44
6. 11.1.2 Explicit Type Conversions
Table 11-1 listed the automatic data type conversions that JavaScript performs. It is also possible to explicitly convert values from one type to another. JavaScript does not define a cast operator as C, C++, and Java do, but it does provide similar facilities for converting data values.
As of JavaScript 1.1 (and the ECMA-262 standard), Number( ) , Boolean( ), String( ), and Object( ) may be called as functions as well as being invoked as constructors. When invoked in this way, these functions attempt to convert their arguments to the appropriate type. For example, you could convert any value x to a string with String(x) and convert any value y to an object with Object(y).
There are a few other tricks that can be useful for performing explicit conversions. To convert a value to a string, concatenate it with the empty string:
var x_as_string = x + "";
To force a value to a number, subtract zero from it:
var x_as_number = x - 0;
And to force a value to boolean, use the ! operator twice:
var x_as_boolean = !!x;
Because of JavaScript's tendency to automatically convert data to whatever type is required, explicit conversions are usually unnecessary. They are occasionally helpful, however, and can also be used to make your code clearer and more precise.
//JavaScript: The Definitive Guide, 4th Edition -- 11.1 Data Type Conversion
2006-10-12 12:36:23
5. Each RegExp object has five properties. The source property is a read-only string that contains the text of the regular e??xpression. The global property is a read-only boolean value that specifies whether the regular e??xpression has the g flag. The ignoreCase property is a read-only boolean value that specifies whether the regular e??xpression has the i flag. The multiline property is a read-only boolean value that specifies whether the regular e??xpression has the m flag. The final property is lastIndex, a read-write integer. For patterns with the g flag, this property stores the position in the string at which the next search is to begin. It is used by the exec( ) and test( ) methods, as described in the previous section.
//JavaScript: The Definitive Guide, 4th Edition -- 10.3.2 RegExp Instance Properties
2006-10-9 21:23:26
4. the RegExp constructor. search( ) does not support global searches -- it ignores the g flag of its regular e??xpression argument.
//JavaScript: The Definitive Guide, 4th Edition -- 10.2 String Methods for Pattern Matching
2006-10-9 19:56:40
3. We've seen the . operator used to access the properties of an object. It is also possible to use the [] operator, which is more commonly used with arrays, to access these properties. Thus, the following two JavaScript e??xpressions have the same value:
object.property
object["property"]
//JavaScript: The Definitive Guide, 4th Edition -- 8.6 Objects as Associative Arrays
2006-10-9 14:45:13
2. The typeof Operator
typeof is a unary operator that is placed before its single operand, which can be of any type. Its value is a string indicating the data type of the operand.
The typeof operator evaluates to "number", "string", or "boolean" if its operand is a number, string, or boolean value. It evaluates to "object" for objects, arrays, and (surprisingly) null. It evaluates to "function" for function operands and to "undefined" if the operand is undefined.
//JavaScript: The Definitive Guide, 4th Edition -- 5.10.2 The typeof Operator
1. JavaScript strings (and JavaScript arrays, as we'll see later) are indexed starting with zero.
---/---------------------------------------------- -----------
小小心得
1. 花括弧定义 对象 元素, 方括弧定义 数组 元素. 2006-10-15 17:55:50
2. Javascript 正则表达式摘要
linenum
Javascript 与正则表达式 By shawl.qiu
语法方法:
5. str.split()
//');
document.write(str.split(/"s*,"s*/).join());
//]]>
4. str.match()
//');
document.write(str.match(/"w+/g).join());
//]]>
3. str.replace()
//');
document.write(str.replace(/^("s+)|("s+)$/g,'----- -----'));
//]]>
2. str.search()
//
1. 子匹配
//
0. 创建正则表达式模式
0.1 new RegExp()
//
-1. re.exec(str)
//');
document.write(('match index: ').bold()+(report.index+'').fontcolor('red')+'' );
document.write(('match lastIndex: ').bold()+(pt.lastIndex+'').fontcolor('red')+'') ;
}
//]]>
-2. re.test(str)
//
发表评论
-
英语 2
2012-01-20 11:36 666英语 2 18小时前 ... -
亲,我们一起分享教育学2
2012-01-20 11:35 584亲,我们一起分享教育学2 2010年04月19日 小学教 ... -
最近学习FLEX4/FMS4的一点小体验【二】
2012-01-19 16:26 766最近学习FLEX4/FMS4的一点小体验【二】 2011年0 ... -
javascript 的 try catch用法
2012-01-19 16:26 695javascript 的 try catch用法 2011年 ... -
js try catch 用法
2012-01-19 16:26 1003js try catch 用法 2011年03月23日 ... -
【FlashCS5】【莫名其妙】之变量 ComponentShim 未定义
2012-01-19 16:26 912【FlashCS5】【莫名其妙】之变量 ComponentSh ... -
VB窗口图表化
2012-01-17 06:11 558VB窗口图表化 2011年04月20日 '本模块为实现托 ... -
VB 两小时
2012-01-17 06:11 576VB 两小时 2011年09月25日 Option Ex ... -
使用 Shell 属性及方法
2012-01-17 06:11 814使用 Shell 属性及方法 2 ... -
VB关机代码
2012-01-17 06:11 604VB关机代码 2011年07月20日 .首先在Form1 ... -
VB 打开网络连接
2012-01-17 06:10 635VB 打开网络连接 2011年10月29日 Option ... -
所有的神马都是浮云
2012-01-16 04:51 576所有的神马都是浮云 2011年11月27日 ... -
神马都是浮云
2012-01-16 04:51 471神马都是浮云 2011年02月28日 2010一切都那么 ... -
神马都是浮云
2012-01-16 04:51 554神马都是浮云 2012年01月06日 ... -
神马都是浮云。
2012-01-16 04:51 513神马都是浮云。 2011年04月15日 ... -
2011的神马,浮云。。
2012-01-16 04:51 5822011的神马,浮云。。 2011年12月27日 年尽, ...
相关推荐
使用本教程可以帮助学习者快速掌握JavaScript的核心知识点,提高JavaScript编程能力。此外,本教程还提供了配套的代码和实例,方便学习者进行实践和巩固。如果你想要系统学习JavaScript,这个教程是你不可错过的资源...
JavaScript常用的方法大全集 项目介绍 JavaScript常用的方法大集合, 里面有对json处理的各种方法, 对时间处理的各种方法。 从手机端,PC端,从ie5到ie11都兼容。 整个项目都是免费开源的。 可以用于开发大型项目...
使用javascript和jquery 操作框架的方法,包括获得元素并赋值、调用其他框架的中的方法
JavaScript常用的方法大全集 项目介绍 JavaScript常用的方法大集合, 里面有对json处理的各种方法, 对时间处理的各种方法。 从手机端,PC端,从ie5到ie11都兼容。 整个项目都是免费开源的。 可以用于开发大型项目...
包括很多js使用的小技巧,或与对大家有用哦
JavaScript知识点思维导图jQuery版本全集 排序算法动画演示 ECMAScript3.0规范英文版.pdfECMAScript5.1规范中文版.pdf HTML5 Canvas 2D API规范1.0中文版.pdf IE、Firefox、Opera和Safari的JavaScript兼容性......
JavaScript常用的方法大全集 项目介绍 JavaScript常用的方法大集合, 里面有对json处理的各种方法, 对时间处理的各种方法。 从手机端,PC端,从ie5到ie11都兼容。 整个项目都是免费开源的。 可以用于开发大型项目...
JavaScript 对象表示语法的子集。 数据在名称/值对中 数据由逗号分隔 大括号保存对象 中括号保存数组 JSON 取值类型 数字(整数或浮点数) 字符串(在双引号中) 逻辑值(true 或 false) 数组(在中括号中...
正则全集 正则表达式使用详 简单的说,正则表达式是一种可以用于模式匹配和替换的强有力的工具。我们可以在几乎所有的基于UNIX系统的工具中找到正则表达式的身影,例如,vi编辑器,Perl或PHP脚本语言,以及awk或sed ...
javascript提供了许多函数供开发人员使用,下面给出一个简单介绍,同时也给出了值得一生典藏的js函数!
Google使用全攻略,html基础教程,HTML页面修改注册表解密,iis技术讲座,J2EE 1.3.1 API,JAVASCRIPT教程,JAVASCRIPT语言教程,javascript源码大全,java联想(中文),java语言入门,JScript中文帮助,jsp精华...
9-30 2 javascript的闭包 js变量作用域 9-30 3 仿超级玛丽兄弟游戏制作 9-30 4 构造方法 对象的常用操作 9-30 5 面向对象的封装 继承 多态 9-30 6 面向对象的封装 继承 多态2 9-5 1.php xml编程①-xml基本介绍 xml...
9-30 2 javascript的闭包 js变量作用域 9-30 3 仿超级玛丽兄弟游戏制作 9-30 4 构造方法 对象的常用操作 9-30 5 面向对象的封装 继承 多态 9-30 6 面向对象的封装 继承 多态2 9-5 1.php xml编程①-xml基本介绍 xml...
react-article-bucket:总结,积累,分享,传播JavaScript各模块核心知识点文章全集,欢迎星级,问题(勿用fork,内容可能随时修改)。webpack核心内容部分请查看专栏:https://github.comliangklfanglwebpack-核心...
我提供的PDF是非扫描文字版,书中的内容是可以复制使用的,并提供源码供大家参考。Bootstrap是目前全球流行、火爆的Web前端开发框架之一。...附录B 第三方插件开发建议 附录C 从2.x迁移到3.x 附录D Glyphicons图标全集
9-30 2 javascript的闭包 js变量作用域 9-30 3 仿超级玛丽兄弟游戏制作 9-30 4 构造方法 对象的常用操作 9-30 5 面向对象的封装 继承 多态 9-30 6 面向对象的封装 继承 多态2 9-5 1.php xml编程①-xml基本介绍 xml...
在这个教程中,我将给你展示如何让简单的添加ajax到你的应用中去,并且教你如何使用一个流行的javascript库Jquey进行ajax开发. 1. 什么是ajax 你以前可能听说过ajax,或者至少用过ajax的应用–比如Gmail.简单的说,ajax...
李炎恢老师在线教程66讲所用的PDF笔记课件,共16章。使用本文档可以省去记笔记的过程。 分享给大家,希望对大家有用。
:smiling_face_with_sunglasses: Azure SWAG演示 ... 它是基于GitHub存储库中的持续部署的,包含使用JavaScript构建的无服务器API的Web应用程序的全包托管服务。 有关带有部署说明的较长版本, 。 您还可以查看。
PHP100视频教程2:PHP的数据类型与源码调试 PHP100视频教程3:常用PHP运算类型介绍与应用 PHP100视频教程4: PHP条件语句介绍与应用 PHP100视频教程5:PHP循环语句的介绍与应用 PHP100视频教程6:PHP数组的创建...