Javascript ÀàºÍÃüÃû¿Õ¼äµÄ¶¨Òå
//1.Àà
function Test(id)
{
this.id=id;
this.method=function()
{
//´úÂë
};
}
//¿ÉÒÔ¼ÌÐøÀ©Õ¹ÉÏÃæµÄ·½·¨£º
Test.prototype.method1=function(){};
//µ÷ÓÃдºÃµÄÀà var A = new Test("1");
//2.JSÃüÃû¿Õ¼ä
var namespace={};//var namespace=new Object();
o.i=4;
o.method1=function(){};
//ÎÒµÄÏë·¨ÊÇ£º¾ÍÊÇÀûÓÃobjectÌØÐÔ£¬¿ÉÒÔÌí¼Ó×Ô¼ºµÄ·½·¨ºÍ±äÁ¿£¬´Ó¶ø´ïµ½·½±ãÉèÖÃÃüÃû¿Õ¼äµÄÄ¿µÄ£»
//ÏÂÃæÊÇÍøÉϵÄÒ»¸ö·½·¨£¬ÎÒ¾õµÃÕâ¸ö±È½Ï·½±ã£¬ÌرðÊÇÃüÃû¿Õ¼äµÄ²ã´Î±È½Ï¶àµÄʱºò£¬ÓÃÕâ¸öÈ¥×¢²á£¬·Ç³£¿ì
<script language="javascript" type="text/javascript">
// Namespace
Namespace =
new
Object();
// register"Grandsoft.GEA"
Namespace.register =
function
(fullNS)
{
// N, GrandsoftGEA
var nsArray = fullNS.split('.'
);
var sEval = ""
;
var sNS = ""
;
for (var
i = 0; i < nsArray.length; i++)
{
if (i != 0) sNS += "."
;
sNS += nsArray[i];
//
// GrandsoftGrandsoft.GEA
sEval +=
"if (typeof(" + sNS + ") == 'undefined') " + sNS +
" = new Object();"
}
if (sEval != ""
) eval(sEval);
}
//JavaScript
// Grandsoft.GEA, Grandsoft.GCM
Namespace.register(
"Grandsoft.GEA"
);
Namespace.register(
"Grandsoft.GCM"
);
// Grandsoft.GEAPerson
Grandsoft.GEA.Person =
function
(name, age)
{
this
.name = name;
this
.age = age;
}
// Personshow()
Grandsoft.GEA.Person.prototype.show =
function
()
{
alert(
this.name + " is " + this.age + " years old!"
);
}
// Person
var
p = new Grandsoft.GEA.Person("yanglf"
, 25);
window.onload = p.show;
</script>
Ïà¹ØÎĵµ£º
ÓÉÓÚ°²È«·½ÃæµÄ¿¼ÂÇ£¬
Javascript
±»ÏÞÖÆÁË¿çÓò·ÃÎʵÄ
ÄÜÁ¦£¬µ«ÊÇÓÐʱºòÎÒÃÇÏ£ÍûÄܹ»×öһЩºÏÀíµÄ¿çÓò·ÃÎʵÄÊÂÇ飬ÄÇôÔõô°ìÄØ£¿
ÕâÀï·ÖÁ½ÀàÇé¿ö£º
Ò»¡¢»ùÓÚͬһ¸¸ÓòµÄ×ÓÓòÖ®¼äÒ³ÃæµÄ·ÃÎÊ
&nb ......
JavaScript µÄ³É¹¦ÈÃÈ˽ò½òÀÖµÀ£¬Îª Web ÍøÒ³±àд JavaScript ´úÂëÒѾÊÇËùÓÐ Web Éè¼ÆʦµÄ»ù±¾¹¦£¬ÕâÃÅÓÐȤµÄÓïÑÔÔ̲Ø×ÅÐí¶à²»ÎªÈËÊìÖªµÄ¶«Î÷£¬¼´Ê¹¶àÄêµÄ JavaScript ³ÌÐòÔ±£¬Ò²Î´ÄÜÍêÈ«³Ô͸¡£±¾ÎÄ´Ó7¸ö·½Ãæ½²Êö JavaScript ÖÐÄÇЩÄã²»ºÜÊìÖªµ«·Ç³£ÊµÓõļ¼ÇÉ¡£
¼òÂÔÓï¾ä
JavaScript ¿ÉÒÔʹÓüòÂÔÓï¾ä¿ìËÙ´´½¨¶ÔÏóºÍÊý× ......
³ÌÐòÉè¼ÆÖлᾳ£Åöµ½Ò»ÖÖÇé¿ö£¬¾ÍÊÇÊÂÏÈÎÞ·¨µÃÖªÓû§»áÐèÒªÄÄЩÊý¾Ý£¬±ØÐë¸ù¾ÝÓû§Ñ¡ÔñºóÔÙ´Ó·þÎñÆ÷
ÖØÐÂÌáÈ¡Êý¾Ýºó·´À¡¸øÓû§¡£±ÈÈçÒ»¼òµ¥µÄÇé¿ö£¬Óû§Ñ¡ÔñÊ¡·ÝÒÔºó£¬ÎÒÃÇÁ¢¼´»áÔÚÊÐÀï±ß½«Õâ¸öÊ¡µÄËùÓÐ
ÊÐÖØÐÂÏÔʾ³öÀ´¡£ÕâÖÖÇé¿öÒ»°ãÐèÒª½«Õû¸öÒ³Ãæˢкó²Å¿ÉÒÔÖØжÁÈ¡£¬µ«ÕâÑù²»½öЧÂʲ»¸ßÍ⣬ҲÏԵò»
Ì«ÓÅÑÅ¡£Æäʵ ......
ÕýÔò±í´ïʽ
RegExp(regexp, option)ÀàʵÏÖ,¿ÉÒÔ¼òд³É/regexp/option
option:
g: global, i: ignore case
·½·¨:string.test(regexp),
string.exec(regexp)[·µ»ØËùÓÐÆ¥ÅäµÄµØ·½], string.serch(regexp)[ÕýÔò°æµÄindexOf()],
string.replace(regexp, str|funtion), string.split(regexp)
¼òµ¥Ä£Ê½
Ôª×Ö·û:( [ {
......