javascriptÊ®½øÖÆת¶þ½øÖÆ£¬¶þ½øÖÆתʮ½øÖÆ
alert(parseInt("101101", 2))
ÔËÐдúÂë
function toBin(intNum) {
var answer = "";
if(/\d+/.test(intNum)) {
while(intNum != 0) {
answer = Math.abs(intNum%2)+answer;
intNum = parseInt(intNum/2);
}
if(answer.length == 0)
answer = "0";
return answer;
} else {
return 0;
}
}
alert(toBin(45))
ÔËÐдúÂë
function toBin(dec) {
var bits = [];
var dividend = dec;
var remainder = 0;
while (dividend >= 2) {
remainder = dividend % 2;
bits.push(remainder);
dividend = (dividend - remainder) / 2;
}
bits.push(dividend);
bits.reverse();
return bits.join("");
}
alert(toBin(45))
ÔËÐдúÂë
Ïà¹ØÎĵµ£º
ugmbbc·¢²¼ÓÚ 2009-11-14 09:41:43| 7628 ´ÎÔĶÁ ×ÖÌ壺´ó С ´òÓ¡Ô¤ÀÀ
var ReTitle = '»Ø¸´:Google ÅÅÃûÖÐµÄ 10 ¸ö×îÖøÃûµÄ JavaScript ¿â';
¸ÐлCOMSHARP CMSµÄͶµÝ
ÐÂÎÅÀ´Ô´:tripwiremagazine.com
JavaScript ÊÇ Web ¿ª·¢ÓëÉè¼ÆÖв»¿É»òȱµÄ¶«Î÷£¬²»¹ÜÊÇÒ»¸ö¼òµ¥µÄÍøÒ³»¹ÊÇÒ»¸öרҵµÄÕ¾µã£¬Ò²²»¹ÜÄãÊǸßÊÖ»¹ÊDzËÄñ ......
µÚ3ÕÂ ¶ÔÏó
JavaScriptµÄ¼òµ¥ÀàÐÍ°üÀ¨Êý×Ö¡¢×Ö·û´®¡¢²¼¶ûÖµ£¨trueºÍfalse£©¡¢nullÖµºÍundefinedÖµ¡£ÆäËûËùÓеÄÖµ¶¼ÊǶÔÏó¡£Êý×Ö¡¢×Ö·û´®ºÍ²¼¶ûÖµ“òËÆ”¶ÔÏó£¬ÒòΪËüÃÇÓµÓз½·¨£¬µ«ËüÃÇÊDz»¿É±äµÄ¡£JavaScriptÖеĶÔÏóÊǿɱäµÄ¼ü-Öµ¼¯ºÏ(keyed collections)¡£ÔÚJavaScriptÖУ¬Êý×éÊǶÔÏ󣬺¯ÊýÊǶÔÏó£¬Õý ......
<html>
<head>
<title></title>
<script language="javascript">
var arr=new Array();
arr[0]=3.5;
arr[1]=300;
arr[2]=50;//»»³É30
arr[3]=1.5;//»»³É40 Ö®ºó¾ÍOKÅÅÐò¾ÍÊÇÉýÐòµÄ
arr[4]=400;
arr.sort();//Õâ¸öÅÅÐò³öÀ´Ôõô²»ÊÇÉýÐòµÄ
for(var i=0;i<arr.length;i++)
{
do ......
ÃèÊö event´ú±íʼþµÄ״̬£¬ÀýÈç´¥·¢event¶ÔÏóµÄÔªËØ¡¢Êó±êµÄλÖü°×´Ì¬¡¢°´ÏµļüµÈµÈ¡£ event¶ÔÏóÖ»ÔÚʼþ·¢ÉúµÄ¹ý³ÌÖвÅÓÐЧ¡£ eventµÄijЩÊôÐÔÖ»¶ÔÌض¨µÄʼþÓÐÒâÒå¡£±ÈÈ磬fromElement ºÍ toElement ÊôÐÔÖ»¶Ô onmouseover ºÍ onmouseout ʼþÓÐÒâÒå¡£ Àý×Ó ÏÂÃæµÄÀý×Ó¼ì²éÊó±êÊÇ·ñÔÚÁ´½ÓÉ ......
1.document.formName.item("itemName") ÎÊÌâ
˵Ã÷:IEÏÂ,¿ÉÒÔʹÓÃdocument.formName.item("itemName")»ò document.formName.elements["elementName"];FirefoxÏÂ,Ö»ÄÜʹÓà document.formName.elements["elementName"].
½â¾ö·½·¨:ͳһʹÓÃdocument.formName.elements["elementName"].
2.¼¯ºÏÀà¶ÔÏóÎÊÌâ
˵Ã÷:IEÏÂ,¿É ......