- 浏览: 231844 次
- 性别:
- 来自: 上海
最新评论
-
uchaoxi:
谢谢作者分享的经验,非常有用!
点击<a>标签,禁止页面自动跳到顶部的解决办法 -
独爱cyjs:
试下用rs.getObject()
有关ResultSet类中getLong方法自动将null转为0的解决方式 -
muyeandmuye:
呃,这里被抄袭了。http://www.myexception ...
CSS3实现红心动态变化效果 -
univasity:
非常不错,很全面。学习了。
javascript,php文件上传详解 -
lord_is_layuping:
...
有关ResultSet类中getLong方法自动将null转为0的解决方式
1、JavaScript does not support multidimensional arrays,except as arrays of arrays.
2、JavaScript is an untyped language, the elements of an array do not all need to be of the same type, as they do in typed languages like Java.
3、Arrays can be created with the Array( ) constructor function.
var a = new Array( );
a[0] = 1.2;
a[1] = "JavaScript";
a[2] = true;
a[3] = { x:1, y:3 };
4、Arrays can also be initialized by passing array elements to the Array( ) constructor. var a = new Array(1.2, "JavaScript", true, { x:1, y:3 });
5、If you pass only a single number to the Array( ) constructor, it specifies the length of the array. Thus:
var a = new Array(10);
creates a new array with 10 undefined elements.
6、Also, as with object literals, the elements in array literals can be arbitrary expressions and need not be restricted to constants:
var base = 1024;
var table = [base, base+1, base+2, base+3];
7、The JavaScript keyword null is a special value that indicates no value. null is usually considered a special value of object typea value that represents no object.
8、When null is used in a Boolean context, it converts to false. When used in a numeric context, it converts to 0. And when used in a string context, it converts to "null".
9、Another special value used occasionally by JavaScript is the undefined value. undefined is 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.
10、Although null and the undefined value are distinct, the == equality operator considers them equal to one another. However, if you truly must distinguish between a null value and an undefined value, use the === identity operator or the typeof operator.
11、When the undefined value is used in a Boolean context, it converts to false. When used in a numeric context, it converts to NaN. And when used in a string context, it converts to "undefined".
12、JavaScript can flexibly convert values from one type to another. When you use a string in an object contexti.e., when you try to access a property or method of the stringJavaScript internally creates a String wrapper object for the string value. This String object is used in place of the primitive string value. The object has properties and methods defined, so the use of the primitive value in an object context succeeds.
13、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.
14、If one operand is or converts to a string, and one is or converts to a number, the operator attempts to convert the string to a number and performs a numerical comparison. If the string does not represent a number, it converts to NaN, and the comparison is false. (In JavaScript 1.1, the string-to-number conversion causes an error instead of yielding NaN.),for example:
var str1 = "notANumber";
var int1 = 1234;
var test1 = (str1 < int1); //return false;
var test2 = (str1 > int1); //return false;
var test3 = (str1 == int1); //return false;
So we can not compare a string with a number as following:
if (str1 < int1) {
document.write("str1 < int1");
} else {
document.write("str1 >= int1");
}
The result is obviously wrong.Thus, we should check the string with isNaN before comparison.
15、If the operands of the comparison operators cannot both be successfully converted to numbers or to strings, these operators always return false.
16、If either operand is or converts to NaN, the comparison operator always yields false.
17、When combining JavaScript and HTML, it is a good idea to use one style of quotes for JavaScript and the other style for HTML.
<a href="" onclick="alert('Thank you')">Click Me</a>
18、In some implementations of JavaScript, individual characters can be read from strings (but not written into strings) using array notation, so the earlier call to charAt( ) can also be written like this:
last_char = s[s.length - 1];
Note, however, that this syntax is not part of the ECMAScript v3 standard, is not portable, and should be avoided.
19、If a number is used where a boolean value is expected, the number is converted to TRue unless the number is 0 or NaN, which are converted to false. If a string is used where a boolean value is expected, it is converted to true except for the empty string, which is converted to false. null and the undefined value convert to false, and any non-null object, array, or function converts to true.
20、The fact that functions are true values in JavaScript gives a lot of flexibility to the language. It means that functions can be stored in variables, arrays, and objects, and it means that functions can be passed as arguments to other functions.
21、Objects in JavaScript can serve as associative arrays
image["width"]
image["height"]
22、The property values used in object literals need not be constants; they can be arbitrary JavaScript expressions. Also, the property names in object literals may be strings rather than identifiers:
var square =
{ "upperLeft": { x:point.x, y:point.y },
'lowerRight': { x:(point.x + side), y:(point.y+side) }};
23、typeof(i)
primitive: "number", "string", "boolean"
arrays, null, String, Number, Boolean, Date,
RegExp, objects, all client-side objects: "object"
function: "function"
undefined: "undefined"
24、typeof is useful only to distinguish objects from other, primitive types. In order to distinguish one object type from another, you must use other techniques, such as the instanceof operator.
25、The most common use for ‘void’ is in a client-side javascript: URL, eg.
<a href="javascript:void window.open( );">Open New Window</a>
When a new window is created, the function will return the window object(the new one) if nothing else. And since this code is called from href attribute, the browser will attempt to go to that returned text, which is the object's toString result:object [object]. So a blank screen usually appears with just that text on it(your original page disappears). Using void operator means that no return is passed to the href.In fact that javascript pseudo-URL technique is obsolete and is best to use:
<a href="#" onclick="window.open( ); return false;">
Open New Window</a>
Besides which, if you use the void() method, and your viewer happens to right-click on the link, and then chooses "Open link in a new window" - a nasty error results. Using onClick() instead at least avoids the error.
26、For 'switch' statement, the matching case is determined using the === identity operator, not the == equality operator, so the expressions must match without any type conversion.
27、for (variable in object)
statement
Before the body of the loop is executed, the name of one of the object's properties is assigned to variable, as a string. Note that it is the properties' name, not the values. The variable in the for/in loop may be an arbitrary expression, this expression is evaluated each time through the loop, which means that it may evaluate differently each time. For example, you can use code like the following to copy the names of all object properties into an array:
var o = {x:1, y:2, z:3};
var a = new Array( );
var i = 0;
for(a[i++] in o) /* empty loop body */;
document.write(a[1]) //array a has been evaluated, and a[1] is 'y' not 2
28、function definitions occur at parse time rather than at runtime(parse time is earlier than runtime ).Consider the following code:
alert(f(4)); // Displays 16. f( ) can be called before it is defined.
var f = 0; // This statement overwrites the property f.
function f(x) { // This "statement" defines the function f before either
return x*x; // of the lines above are executed.
}
alert(f); // Displays 0. f( ) has been overwritten by the variable f.
29、Array and Object
/* Array is a special object, so it can have properties */
var a = [1, 2, 3, 4];
a["new"] = 16;
document.write(a.length); //4, a["new"] is not a new element of array, but a property
document.write(a.new); //16
/* Adding array elements to an object does not make it an array */
var o = {x:1, y:2};
o[0] = 21;
document.write(o.length); //undefined
document.write(o.0); //error
document.write(o[0]); //21
2、JavaScript is an untyped language, the elements of an array do not all need to be of the same type, as they do in typed languages like Java.
3、Arrays can be created with the Array( ) constructor function.
var a = new Array( );
a[0] = 1.2;
a[1] = "JavaScript";
a[2] = true;
a[3] = { x:1, y:3 };
4、Arrays can also be initialized by passing array elements to the Array( ) constructor. var a = new Array(1.2, "JavaScript", true, { x:1, y:3 });
5、If you pass only a single number to the Array( ) constructor, it specifies the length of the array. Thus:
var a = new Array(10);
creates a new array with 10 undefined elements.
6、Also, as with object literals, the elements in array literals can be arbitrary expressions and need not be restricted to constants:
var base = 1024;
var table = [base, base+1, base+2, base+3];
7、The JavaScript keyword null is a special value that indicates no value. null is usually considered a special value of object typea value that represents no object.
8、When null is used in a Boolean context, it converts to false. When used in a numeric context, it converts to 0. And when used in a string context, it converts to "null".
9、Another special value used occasionally by JavaScript is the undefined value. undefined is 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.
10、Although null and the undefined value are distinct, the == equality operator considers them equal to one another. However, if you truly must distinguish between a null value and an undefined value, use the === identity operator or the typeof operator.
11、When the undefined value is used in a Boolean context, it converts to false. When used in a numeric context, it converts to NaN. And when used in a string context, it converts to "undefined".
12、JavaScript can flexibly convert values from one type to another. When you use a string in an object contexti.e., when you try to access a property or method of the stringJavaScript internally creates a String wrapper object for the string value. This String object is used in place of the primitive string value. The object has properties and methods defined, so the use of the primitive value in an object context succeeds.
13、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.
14、If one operand is or converts to a string, and one is or converts to a number, the operator attempts to convert the string to a number and performs a numerical comparison. If the string does not represent a number, it converts to NaN, and the comparison is false. (In JavaScript 1.1, the string-to-number conversion causes an error instead of yielding NaN.),for example:
var str1 = "notANumber";
var int1 = 1234;
var test1 = (str1 < int1); //return false;
var test2 = (str1 > int1); //return false;
var test3 = (str1 == int1); //return false;
So we can not compare a string with a number as following:
if (str1 < int1) {
document.write("str1 < int1");
} else {
document.write("str1 >= int1");
}
The result is obviously wrong.Thus, we should check the string with isNaN before comparison.
15、If the operands of the comparison operators cannot both be successfully converted to numbers or to strings, these operators always return false.
16、If either operand is or converts to NaN, the comparison operator always yields false.
17、When combining JavaScript and HTML, it is a good idea to use one style of quotes for JavaScript and the other style for HTML.
<a href="" onclick="alert('Thank you')">Click Me</a>
18、In some implementations of JavaScript, individual characters can be read from strings (but not written into strings) using array notation, so the earlier call to charAt( ) can also be written like this:
last_char = s[s.length - 1];
Note, however, that this syntax is not part of the ECMAScript v3 standard, is not portable, and should be avoided.
19、If a number is used where a boolean value is expected, the number is converted to TRue unless the number is 0 or NaN, which are converted to false. If a string is used where a boolean value is expected, it is converted to true except for the empty string, which is converted to false. null and the undefined value convert to false, and any non-null object, array, or function converts to true.
20、The fact that functions are true values in JavaScript gives a lot of flexibility to the language. It means that functions can be stored in variables, arrays, and objects, and it means that functions can be passed as arguments to other functions.
21、Objects in JavaScript can serve as associative arrays
image["width"]
image["height"]
22、The property values used in object literals need not be constants; they can be arbitrary JavaScript expressions. Also, the property names in object literals may be strings rather than identifiers:
var square =
{ "upperLeft": { x:point.x, y:point.y },
'lowerRight': { x:(point.x + side), y:(point.y+side) }};
23、typeof(i)
primitive: "number", "string", "boolean"
arrays, null, String, Number, Boolean, Date,
RegExp, objects, all client-side objects: "object"
function: "function"
undefined: "undefined"
24、typeof is useful only to distinguish objects from other, primitive types. In order to distinguish one object type from another, you must use other techniques, such as the instanceof operator.
25、The most common use for ‘void’ is in a client-side javascript: URL, eg.
<a href="javascript:void window.open( );">Open New Window</a>
When a new window is created, the function will return the window object(the new one) if nothing else. And since this code is called from href attribute, the browser will attempt to go to that returned text, which is the object's toString result:object [object]. So a blank screen usually appears with just that text on it(your original page disappears). Using void operator means that no return is passed to the href.In fact that javascript pseudo-URL technique is obsolete and is best to use:
<a href="#" onclick="window.open( ); return false;">
Open New Window</a>
Besides which, if you use the void() method, and your viewer happens to right-click on the link, and then chooses "Open link in a new window" - a nasty error results. Using onClick() instead at least avoids the error.
26、For 'switch' statement, the matching case is determined using the === identity operator, not the == equality operator, so the expressions must match without any type conversion.
27、for (variable in object)
statement
Before the body of the loop is executed, the name of one of the object's properties is assigned to variable, as a string. Note that it is the properties' name, not the values. The variable in the for/in loop may be an arbitrary expression, this expression is evaluated each time through the loop, which means that it may evaluate differently each time. For example, you can use code like the following to copy the names of all object properties into an array:
var o = {x:1, y:2, z:3};
var a = new Array( );
var i = 0;
for(a[i++] in o) /* empty loop body */;
document.write(a[1]) //array a has been evaluated, and a[1] is 'y' not 2
28、function definitions occur at parse time rather than at runtime(parse time is earlier than runtime ).Consider the following code:
alert(f(4)); // Displays 16. f( ) can be called before it is defined.
var f = 0; // This statement overwrites the property f.
function f(x) { // This "statement" defines the function f before either
return x*x; // of the lines above are executed.
}
alert(f); // Displays 0. f( ) has been overwritten by the variable f.
29、Array and Object
/* Array is a special object, so it can have properties */
var a = [1, 2, 3, 4];
a["new"] = 16;
document.write(a.length); //4, a["new"] is not a new element of array, but a property
document.write(a.new); //16
/* Adding array elements to an object does not make it an array */
var o = {x:1, y:2};
o[0] = 21;
document.write(o.length); //undefined
document.write(o.0); //error
document.write(o[0]); //21
发表评论
-
一个让以各种类型元素为容器的“按钮”都文字居中的方法
2013-06-29 13:05 1344最近在做一个Button控件,这个控件不仅限于使用 ... -
JS类中能模拟出依赖对象本身的可变的私有属性吗?
2012-11-22 16:11 827JS是轻量级语言,在类的概念上没有如Java那样严格意义上私有 ... -
LESS —— 动态样式语言 学习纪要
2012-08-30 18:54 8980学习LESS源于一次分享的要求。之前一直没有使用,是因为使用这 ... -
CSS学习笔记
2012-07-09 22:35 1579使用CSS有些年头了,但是很惭愧从来没有系统的看过一本书,基本 ... -
阶段性总结。。。
2012-05-16 17:29 913自己的空间,不说废话 ... -
页面中包含大比率压缩图片会损耗内存
2011-12-25 23:58 1123最近做了一个类似美丽说的图片分享网站,测试时发现打开某个网页时 ... -
上传图片一直不变的问题 | IE的file无法手动置空
2011-11-19 04:15 1745今天在开发一个图片上传控件的时候,发现在IE8下上传一张 ... -
做一个资源加载进度条
2011-11-14 15:51 5094最近在开发一个工具类的网站,网站的背景和各模块的构建都需要加载 ... -
【Frontend Knowlodge Chart】 学习之安全相关
2011-10-20 19:54 1271安全相关 考查前端及 ... -
【Frontend Knowlodge Chart】 学习之HTTP协议
2011-10-20 19:53 1300HTTP协议 考查HTTP协议的认知程度和基本知识 ... -
【转】Frontend Knowlodge Chart
2011-10-17 16:21 1151转一个牛人总结的前端知识框架图 http://www ... -
我最近新学会的XXX
2011-09-01 18:28 1142最近忙上,忙下,忙里,忙外,活儿做了不少。这里有重复劳动 ... -
【转】Firefox下iframe的onload事件有可能无法触发 作者:zhanglili
2011-05-31 14:29 5662Firefox下,已经load的document,重新open ... -
避免function的循环引用
2011-05-26 16:44 902循环引用 window.onload = functi ... -
如何获取一个dom元素的绝对位置
2011-05-18 12:05 6047应用场景:鼠标滑过某元素时,需要弹出一个信息标签,标签的 ... -
关于CSS Selector的优先级
2011-05-16 15:27 1604用CSS这么些年,从来没从算法级别考虑过它的优先级原理,只是凭 ... -
javascript,php文件上传详解
2011-04-29 19:20 3995今儿说点儿基础但是蛮重要的前端技术——使用file ... -
IE6下left绝对定位诡异错误
2011-04-29 01:44 1795今天开发自己的一个小网站时出现一个诡异的错误:目标 ... -
推荐个学WEBGL的网站
2011-04-12 17:59 852http://learningwebgl.com/blog/? ... -
【转】浅谈跨域WEB攻击
2011-04-08 17:54 1001转自http://www.80sec.com/cros ...
相关推荐
个人Javascript学习笔记 精华版 本资源为个人Javascript学习笔记的精华版,涵盖了Javascript的基础知识、事件处理、对象和系统函数、浏览器对象等方面的内容。下面是对每个知识点的详细说明: 1. 什么是JavaScript...
### JavaScript学习笔记精要 #### JavaScript简介 JavaScript是一种强大的、多用途的脚本语言,用于增强网站的交互性和用户体验。它是由Netscape公司的Brendan Eich在1995年发明的,并且迅速成为了Web开发的标准之...
JavaScript学习笔记讲解版参考.pdf是一份详尽的教程,涵盖了从基础到进阶的JavaScript知识。这份笔记首先从CSS样式表开始,引导读者理解网页样式的设置与应用。 1. CSS(Cascading Style Sheets)样式表是用于控制...
这份“javascript学习笔记整理知识点整理”是针对初学者的一份宝贵资料,涵盖了JavaScript的基础知识,旨在帮助新手快速入门并掌握这门语言的核心概念。 一、变量与数据类型 在JavaScript中,变量用于存储数据。...
JavaScript基础知识点总结 JavaScript是一种高级的、动态的、基于对象的客户端脚本语言。它是在网页上执行的脚本语言,能实现网页的交互功能。下面是该资源中的重要知识点总结: 一、 JavaScript 基本概念 * ...
JavaScript学习笔记是一本关于JavaScript编程语言的教材,该教材通过丰富的实例,系统地介绍了JavaScript的基础知识和实际应用技巧,帮助读者一步步掌握客户端编程技术。本书共分为九章,每一章都有其特定的主题,...
根据提供的文件信息,可以看出这份“我的javascript学习笔记”主要涵盖了JavaScript中的几个关键概念和技术要点,包括正则表达式、AJAX以及一些JavaScript的核心语言特性。接下来将这些知识点进行详细的整理和解释。...
JavaScript 学习笔记集和代码库JavaScript 学习笔记集和代码库JavaScript 学习笔记集和代码库JavaScript 学习笔记集和代码库JavaScript 学习笔记集和代码库JavaScript 学习笔记集和代码库JavaScript 学习笔记集和...
JavaScript学习笔记——深入理解基础与函数 在JavaScript中,学习基础知识是至关重要的,因为它是所有进一步编程技巧的基础。首先,我们需要了解JavaScript中的数据类型。在JavaScript中,有五种简单的数据类型:...
"Javascript学习笔记(传智播客视频学习笔记+代码)"是一份全面介绍JavaScript基础知识的学习资源,适用于初学者。这份笔记结合了传智播客的web前端培训视频内容,提供了丰富的理论讲解和实践代码,帮助读者从零开始...
这只是JavaScript学习笔记的一小部分,JavaScript还有更多高级特性和概念,如对象、数组、函数、类、模块、闭包等,以及DOM操作、事件处理、Ajax异步请求等内容,需要进一步深入学习和实践才能掌握。
这个“javaScript学习笔记.rar”压缩包显然包含了作者在学习JavaScript过程中的心得和记录,对于初学者或者想要深入理解JavaScript的人来说,是一份宝贵的资源。 JavaScript与Java虽然名字相似,但两者实际上是不同...
《蓝杰JavaScript学习笔记》是一份综合性的JavaScript学习资料,主要涵盖了JavaScript在网页动态操作、DOM操作以及事件处理等方面的基础知识。这篇笔记通过多个实例文件,如`dynamicCreateTable.htm`、`...