Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

javascriptÊý×éΨһ»¯ÊµÏÖ·½Ê½

ʵÏÖ·½Ê½
ÕâÀï¸ø³ö2ÖÐʵÏÖ·½Ê½¡£Ò»ÖÖÊÇ´ó¼ÒÓ¦¸Ã¶¼ÖªµÀµÄindexOf¼ì²âµÄ·½Ê½£¬ÁíÒ»ÖÖÊǽáºÏlastIndexOfºÍspliceʵÏÖ·½Ê½¡£
//Ê×ÏȸøArray¶ÔÏóÔ­ÐÍÉÏÌí¼ÓindexOfºÍlastIndexOf·½·¨.(Èç¹ûûÓеĻ°)
if(!Array.prototype.indexOf){
Array.prototype.indexOf = function(element, index){
var length = this.length;
if(index == null){
index = 0;
}else{
index = +index || 0;
if(index < 0) index+= length;
if(index < 0) index = 0;
}
for(var current;index<length;index++){
current = this[index];
if(current === element) return index;
}
return -1;
}
}
if(!Array.prototype.lastIndexOf){
Array.prototype.lastIndexOf = function(element, index){
var length = this.length;
if(index == null){
index = length - 1;
}else{
index = +index || 0;
if(index < 0) index+= length;
if(index < 0) index = -1;
else if(index >= length) index = length - 1;
}
for(var current;index>=0;index--){
current = this[index];
if(current === element) return index;
}
return -1;
}
}
//ºÜ³£¼ûµÄʵÏÖ·½Ê½
var arrayUnique1 = function(arr){
for(var i=0,len=arr.length,result=[],item;i<len;i++){
item = arr[i];
if(result.indexOf(item) < 0) {
result[result.length] = item;
}
}
return result;
}
//ͨ¹ýlastIndexOfºÍsplice·½·¨ÊµÏÖ·½Ê½
var arrayUnique2 = function(arr){
var length = arr.length;
while(--length){
//Èç¹ûÔÚÇ°ÃæÒѾ­³öÏÖ£¬Ôò½«¸ÃλÖõÄÔªËØɾ³ý
if(arr.lastIndexOf(arr[length],length-1) > -1) {
arr.splice(length,1);
}
}
return arr;
}

²âÊÔ½á¹û
²âÊÔÊý¾Ý£ºvar arr = [1,2,3,1,2,3,2,1,3,4,2,232];
IE7Ñ­»·10,000´Î£º
arrayUnique1Ϊ460ms£¬arrayUnique2Ϊ190ms¡£
FF3.5Ñ­»·100,000´Î£º


Ïà¹ØÎĵµ£º

дµÄµÚÒ»¸ö½ÏÓÐÒâÒåJavascript³ÌÐò

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>javascript</t ......

$wnd and $doc Calling native JavaScript with JSNI

$wnd and $doc Calling native JavaScript with JSNI
$wnd ÊÇʲô£¿
GWT provides the $wnd and $doc variables to refer to the window and document objects
GWTʹÓÃͨ¹ýJava Native methodʹÓÃËü£¬ÉùÃ÷Ò»¸önative·½·¨£¬½«º¬ÓÐJavaScriptµÄ·½·¨Ìå×¢ÊÍ¡£±àÒëÆ÷½«×¢ÊÍ¿éÄÚµÄÄÚÈÝÖð×ÖÊä³ö£¬Ê¹Ö®Óë±àÒë²úÉúµÄJavaScriptÕûº ......

7 JavaScript Differences Between Firefox & IE

Although the days of long and tedious code branches to target specific browsers in JavaScript are over, once in a while it's still necessary to do some simple code branching and object detection to ensure that a certain piece of code is working properly on a user's machine. 
In this article, I ......

javascriptÖÐFORM±íµ¥µÄsubmit()·½·¨¾­Ñé½Ìѵ

@author    songfeng     
       ÒòΪJSÄÚ¶ÔÏóµÄ·½·¨Êµ¼ÊÉÏÊÇ´æ´¢Óï¾äµÄÒ»¸öÀàËÆÓÚÖ¸ÕëµÄ¶«Î÷. ÆäÖ¸ÏòÁËÄÚ´æµÄÒ»¸öλÖÃ, Ò²¾ÍÊÇÆ亯ÊýµÄλÖÃ,µ±È»Ò²¿ÉÒÔÈÃÆäÖ¸ÏòÒ»¸ö±äÁ¿Öµ.
       var foo = new Object();
&nbs ......

Javascript¼ì²âMedia Player°æ±¾£¡

      ÔÚweb¿ª·¢¹ý³ÌÖУ¬¾­³£»á³öÏÖÒòΪ¿Í»§¶ËµÄijЩÈí¼þ°æ±¾ÎÊÌ⣬¶øµ¼ÖÂÖÖÖÖÎÊÌâ¡£ÕâÀ´Ìì¾ÍÒòΪMedia Player°æ±¾µÄÎÊÌ⣬Òý·¢ÁËÒ»¸ö²»´ó²»Ð¡µÄÎÊÌâ¡£ÔÚµ÷ÓÃMedia Player²¥·ÅÊÓƵµÄʱºò£¬Media Player9¾¹È»²¥·Å²»ÁË ...  ...
 
²»¶à˵ÁË£¬»¹ÊÇÌù´úÂë°É£¡
 
<html xmlns="h ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ