javascript È¥µôÊý×éÖÐÇ°»òºóÖظ´Ïî
ÏÂÃæÁ½¸ö·½·¨ÊµÏÖÁËÊý×éÖÐÈ¥µô Ç°Ãæ »òÕß ºóÃæµÄ Öظ´Ïî
È¥µôÇ°ÃæµÄÖظ´Ïî·½·¨ °Ñarray [1, 2, 3, 1, 4, 5]È¥µôÇ°ÃæÖظ´Ïî µÃµ½ [2, 3, 1, 4, 5].
function unique(a)
{
var r = new Array();
o:for(var i = 0, n = a.length; i < n; i++) {
for(var x = i + 1 ; x < n; x++)
{
if(a[x]==a[i]) continue o;
}
r[r.length] = a[i];
}
return r;
}
È¥µôºóÃæµÄÖظ´Ïî·½·¨ °Ñarray [1, 2, 3, 1, 4, 5]È¥µôºóÃæÖظ´Ïî µÃµ½ [1, 2, 3, 4, 5].
function unique(a)
{
var r = new Array();
o:for(var i = 0, n = a.length; i < n; i++)
{
for(var x = 0, y = r.length; x < y; x++)
{
if(r[x]==a[i]) continue o;
}
r[r.length] = a[i];
}
return r;
}
Ïà¹ØÎĵµ£º
·µ»Ø JavaScript È«¾Ö¶ÔÏó²Î¿¼ÊÖ²á
¶¨ÒåºÍÓ÷¨
isNaN() º¯ÊýÓÃÓÚ¼ì²éÆä²ÎÊýÊÇ·ñÊÇ·ÇÊý×ÖÖµ¡£
Óï·¨
isNaN(x)
²ÎÊýÃèÊö
x
±ØÐè¡£Òª¼ì²âµÄÖµ¡£
·µ»ØÖµ
Èç¹û x ÊÇÌØÊâµÄ·ÇÊý×ÖÖµ NaN£¨»òÕßÄܱ»×ª»»ÎªÕâÑùµÄÖµ£©£¬·µ»ØµÄÖµ¾ÍÊÇ true¡£Èç¹û x ÊÇÆäËûÖµ,Ôò·µ»Ø false¡£
˵Ã÷
isNaN() º¯Êý¿ÉÓÃÓÚÅжÏÆä²ÎÊýÊÇ·ñÊÇ NaN£ ......
ÄãÖªµÀÊÀ½çÉÏÓжàÉÙÖÖä¯ÀÀÆ÷Â𣿳ýÁËÎÒÃÇÊìÖªµÄIE, Firefox, Opera, SafariËÄ´óä¯ÀÀÆ÷Ö®Í⣬ÊÀ½çÉÏ»¹Óнü°ÙÖÖä¯ÀÀÆ÷¡£
¼¸ÌìÇ°£¬ä¯ÀÀÆ÷¼Ò×åÓиյ®ÉúÁËһλСÍõ×Ó£¬¾ÍÊÇGoogleÍƳöµÄChromeä¯ÀÀÆ÷¡£ÓÉÓÚChrome³öÉúÃûÃÅ£¬¾¡¹ÜËû»¹ÊǸöС¼Ò»ï£¬Ã»ÓÐÈ˸ÒС ......
ÔÚwebÉϱàд²Ëµ¥Ò»Ö±ÊDZȽÏÍ·ÌÛµÄÊÂÇ飬ҪÊÇÓиöÀàÖ±½ÓÌ×ÓþͺÃÁË£¬×î½üÓÖÒª×öÍøÕ¾ÁË£¬·³ÈË£¬ÒªÇó×öµÄ»¹ÊǶ༶²Ëµ¥£¬°¦£¬·Ï»°ÉÙ˵£¬Óöµ½ÎÊÌâ¾ÍÒª½â¾ö°¡£¬¿´´úÂ룺
function is(e, handler) {
if (e.type != 'mouseout' && e.type != 'mouseover ......
javascript ÀඨÒå4ÖÖ·½·¨
Java´úÂë
/*
¹¤³§·½Ê½--- ´´½¨²¢·µ»ØÌض¨ÀàÐ͵ĶÔÏóµÄ ¹¤³§º¯Êý £¨ factory function £©
*/
function createCar(color,doors,mpg){
......
Ïê½âjavascriptÀà¼Ì³Ð»úÖƵÄÔÀí
Ä¿Ç° javascriptµÄʵÏּ̳з½Ê½²¢²»ÊÇͨ¹ý“extend”¹Ø¼ü×ÖÀ´ÊµÏֵģ¬¶øÊÇͨ¹ýconstructor functionºÍprototypeÊôÐÔÀ´ÊµÏּ̳С£Ê×ÏÈÎÒÃÇ´´½¨Ò»¸öanimalÀà
js ´úÂë
var animal = function(){ //Õâ¾ÍÊÇconstructor function ÁË&nbs ......