
//ÔÚµ±Ç°Ò³ÃæÄÚ×·¼Ó»»ÐбêÇ©ºÍÖ¸¶¨µÄHTMLÄÚÈÝ
function w( html ){
document.body.innerHTML += "<br/>" + html;
}
var x = { name:"CodeMan" };
var y = { age: 18 };
var z = { site: "http://www.cnblogs.com/wang-meng/" };
var obj = $.extend( x, y, z );
w( obj === x ); // true
w( obj.name ); // CodeMan
w( obj.age ); // 18
w( obj.site ); //

(2)jQuery.makeArray( obj )
º¯ÊýÓÃÓÚ½«Ò»¸öÀàÊý×é¶ÔÏóת»»ÎªÕæÕýµÄÊý×é¶ÔÏó¡£
ÀàÊý×é¶ÔÏóÊǷdz£³£¼ûµÄ: ÀýÈçÎÒÃǾ³£Ê¹ÓõÄjQuery¶ÔÏ󡢺¯ÊýÄÚµÄarguments¶ÔÏ󣬶¼ÊÇÀàÊý×é¶ÔÏó¡£
jQuery.makeArray()º¯Êý: ÎÒÃÇ¿ÉÒÔ½«ÀàÊý×é¶ÔÏóת»»ÎªÒ»¸öÕæÕýµÄÊý×é¶ÔÏ󣬴ӶøʹÓÃÊý×é¶ÔÏóµÄÄÚÖ÷½·¨¡£
ʾÀýÈçÏÂ:

<p>¶ÎÂä1</p>
<p>¶ÎÂä2</p>
//ÔÚµ±Ç°Ò³ÃæÄÚ×·¼Ó»»ÐбêÇ©ºÍÖ¸¶¨µÄHTMLÄÚÈÝ
function w( html ){
document.body.innerHTML += "<br/>" + html;
}
// jQuery¶ÔÏóÒ²ÊÇÒ»¸öÀàÊý×é¶ÔÏó
var $p = $("p");
var arr1 = $.makeArray( $p );
w( $p instanceof Array ); // false
w( arr1 instanceof Array ); // true
// NodeList¶ÔÏóÒ²ÊÇÒ»¸öÀàÊý×é¶ÔÏó
var p = document.getElementsByTagName("p");
var arr2 = $.makeArray( p );
w( p instanceof Array ); // false
w( arr2 instanceof Array ); // true
function foo(a, b){
//arguments¶ÔÏóÒ²ÊÇÒ»¸öÀàÊý×é¶ÔÏó
//argumentsÊÇÊÕµ½µÄʵ²Î¸±±¾£¬
var arr3 = $.makeArray( arguments );
w( arguments instanceof Array ); // false
w( arr3 instanceof Array ); // true
}
foo(1, 2);

(3)jQuery.inArray( value, array )
value: ÈÎÒâÀàÐÍÓÃÓÚ²éÕÒµÄÖµ¡£
array: ArrayÀàÐÍÖ¸¶¨±»²éÕÒµÄÊý×é¡£
º¯ÊýÓÃÓÚÔÚÊý×éÖÐËÑË÷Ö¸¶¨µÄÖµ£¬²¢·µ»ØÆäË÷ÒýÖµ¡£Èç¹ûÊý×éÖв»´æÔÚ¸ÃÖµ£¬Ôò·µ»Ø -1¡£
ʾÀýÈçÏÂ:

//ÔÚµ±Ç°Ò³ÃæÄÚ×·¼Ó»»ÐбêÇ©ºÍÖ¸¶¨µÄHTMLÄÚÈÝ
function w( html ){
document.body.innerHTML += "<br/>" + html;
}
var arr = [ 10, 25, 3, 0, -3 ];
w( $.inArray( 25, arr ) ); // 1
w( $.inArray( -3, arr ) ); // 4
w( $.inArray( 10, arr ) ); // 0
// Êý×éÖÐûÓÐ99
w( $.inArray( 99, arr ) ); // -1
// Êý×éÖÐÓÐÊý×Ö10£¬µ«ÊÇûÓÐ×Ö·û´®"10"
w( $.inArray( "10", arr ) ); // -1

(4)jQuery.merge( first, second )
ºÏ²¢Á½¸öÊý×é
·µ»ØµÄ½á¹û»áÐ޸ĵÚÒ»¸öÊý×éµÄÄÚÈÝ¡ª¡ªµÚÒ»¸öÊý×éµÄÔªËغóÃæ¸ú×ŵڶþ¸öÊý×éµÄÔªËØ¡£
Ҫȥ³ýÖظ´ÏÐèҪʹÓÃ$.unique()
ºÏ²¢Á½¸öÊý×éµ½µÚÒ»¸öÊý×éÉÏ:
$.merge( [0,1,2], [2,3,4] )
½á¹û:
[0,1,2,2,3,4]
(5)jQuery.unique( array )
ɾ³ýÊý×éÖÐÖظ´ÔªËØ¡£Ö»´¦Àíɾ³ýDOMÔªËØÊý×飬¶ø²»ÄÜ´¦Àí×Ö·û´®»òÕßÊý×ÖÊý×é¡£
$.unique( [0,1,2], [2,3,4] )
½á¹û:
[0,1,2,3,4]
(6)arguments(Ôö¼ÓÄÚÈÝ)
Javascript²¢Ã»ÓÐÖØÔغ¯ÊýµÄ¹¦ÄÜ£¬µ«ÊÇArguments¶ÔÏóÄܹ»Ä£ÄâÖØÔØ¡£JavascripÖÐÿ¸öº¯Êý¶¼»áÓÐÒ»¸öArguments¶ÔÏóʵÀýarguments£¬ËüÒýÓÃן¯ÊýµÄʵ²Î£¬¿ÉÒÔÓÃÊý×éϱêµÄ·½Ê½"[]"ÒýÓÃargumentsµÄÔªËØ¡£
arguments.lengthΪº¯Êýʵ²Î¸öÊý£¬arguments.calleeÒýÓú¯Êý×ÔÉí¡£
ʾÀýÈçÏÂ:

function test(){
// Ñ»·Êä³öµ÷Óõ±Ç°º¯Êýʱ´«ÈëµÄ²ÎÊý
for(var n = 0; n < arguments.length; n++){
document.write( arguments[n] + "|");
}
document.write(¡®<br>¡®); // Êä³ö»»Ðзû½øÐÐÇø·Ö
};
test(); // (¿Õ×Ö·û´®)
test("Code", "http://www.cnblogs.com/wang-meng/", 12, true); // Code||12|true|
test("ÕÅÈý", false, 12.315); // ÕÅÈý|false|12.315|
function foo(){
// argumentsÇ°Ò²¿ÉÒÔ¼ÓÉϺ¯ÊýÃû³Æ
for(var n = 0; n < foo.arguments.length; n++){
document.write( foo.arguments[n] + "|");
}
document.write(¡®<br>¡®);
};
foo("Hello", "World"); // Hello|World|
// ʹÓÃarguments¶ÔÏóʵÏÖÈÎÒâ¶à¸öÊýµÄÇóºÍ
function sum(){
var sum = arguments[0];
for(var n = 1; n < arguments.length; n++){
sum += arguments[n];
}
return sum;
}
document.writeln( sum() ); // undefined
document.writeln( sum( 1, 5 ) ); // 6
document.writeln( sum( 1, 212, 21, -14, 23 ) ); // 243

5£¬ÆäËû
ÆäËû¸ü¶à¹ØÓÚÊý×éµÄ²Ù×÷Çë²é¿´: W3School JS Array
ÒÔÉÏÄÚÈݽÔÊÇ×Ô¼ºÑ§Ï°ÖÐÕûÀí³öÀ´µÄÄÚÈÝ, ÈçÓÐç¢Â©Çë´ó¼Ò¿´µ½¿ÉÒÔÌáÐÑÒ»ÏÂ. ÕûÀí¼Ç¼ÔÚÕâÀïËãÊǶÔ×Ô¼ºÑ§Ï°µÄÒ»¸ö×ܽá, ¸øÈÕºóµÄÍü¼ÇµÄ×Ô¼ºÒ»¸ö²Î¿¼.
Ó¢ÓïСÌùÊ¿£º
Good for you¡£
ºÃ°¡£¡×öµÃºÃ£¡
Great minds think alike£¡
Ó¢ÐÛËù¼ûÂÔͬ£¡
Have a nice day.
×£Äã½ñÌìÓä¿ì¡£
Have butterflies in one¡®s stomach.
½ôÕÅ¡£
He¡®s been everywhere.
Ëûµ½´¦¶¼È¥¹ýÁË¡£
He hit the ceiling at the news.
ËûÌýµ½ÄÇÏûÏ¢±©ÌøÈçÀ×/´ó·¢À×öª¡£
His argument doesn¡®t hold water.
ËûµÄÂÛµãÕ¾²»×¡½Å¡£
How do I address you?
ÎÒÔõô³ÆºôÄ㣿
¡¡