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

javascriptÉè¼ÆÄ£Ê½_µÚ¶þ²¿·Ö_µ¥Ìåģʽ

 µ¥Ìåģʽ
Óŵã:°Ñ´úÂë×éÖ¯µÃÒ»Ö²¢¸ôÀë,¸üÈÝÒ×ÔĶÁºÍά»¤,Ìá¸ßÎȶ¨ÐÔ;ÓÃÓÚÓÅ»¯,ÌáÉýÐÔÄÜ
ȱµã:¿Éµ¼ÖÂÇ¿ñîºÏ
5.1 µ¥ÌåµÄ»ù±¾½á¹¹
var Singleton = {
attribute1 : true,
attribute2 : 10,

method1 : function(){},
method2 : function(){}
};

Ñϸñ°´¶¨ÒåÀ´Ëµ,C1²»ÊÇÒ»¸öµ¥Ìå,ÒòΪËü²»ÊÇÒ»¸ö¿ÉʵÀý»¯µÄÀà
¶ÔÏó×ÖÃæÁ¿Ö»ÊÇ´´Òâµ¥ÌåµÄ·½Ê½Ö®Ò».
²¢·ÇËùÓеĶÔÏó×ÖÃæÁ¿¶¼Êǵ¥Ìå,Ö»ÓÃÀ´Ä£·Â¹ØÁªÊý×é¼°ÈÝÄÉÊý¾ÝµÄ¾Í²»Êǵ¥Ìå.
5.2 »®·ÖÃüÃû¿Õ¼ä
var MyNamespace = {}
MyNamespace.common = {};

5.3 ÓÃ×÷ÌØ¶¨ÍøÒ³×¨ÓôúÂëµÄ°ü×°Æ÷µÄµ¥Ìå
GiantCorp.RegPage = {
FORM_ID : 'reg-form',
//method
handSubmit : function(e){
e.preventDefault();
//...
GiantCorp.RegPage.sendRegistration();
},
init : function(){
GiantCorp.RegPage.formEl = $(GiantCorp.RegPage.FORM_ID);
addEvent(GiantCorp.RegPage.formEl,'submit',GiantCorp.RegPage.handSubmit);
}

};
addLoadEvent(GiantCorp.RegPage.init);
//ÒÔÉÏ´úÂ뽫ÊôÐÔ¼°·½·¨¶¼Í³Ò»µ½Ò»¸öµ¥ÌåÖÐ,²¢Í¨¹ýinitÀ´°ó¶¨Ê¼þ,×îºóÔÚÒ³ÃæÉϵ÷ÓÃinit¼´¿ÉʵÏÖÌØ¶¨Ò³ÃæµÄʹÓÃ

Ä³ÍøÒ³×¨ÓôúÂë,×îºÃâÊÔÚ×Ô¼ºµÄµ¥Ìå¶ÔÏóÖÐ
5.4 ÓµÓÐ˽ÓóÉÔ±µÄµ¥Ìå
 1) Ï»®Ïß±íʾ·¨
GiantCorp.DataParser = {
//Private methods
_stripWhitespace : function(str){
return str.replace(/\s+/,'');
},
_stringSplit : function(str,delimiter){
return str.split(delimiter);
},
//Public method
stringToArray : function(str, delimiter,stripWS){
if(stripWS){
str = this._stripWhitespace(str);
}
var outputArray = this._stringSplit(str,delemiter);
return outputArray;
}
}

    2) ʹÓñհü
     MyNamespace.Singleton = (function(){
return {};
})();

ÕâÖÖ·½Ê½ÓëÖ±½ÓʹÓöÔÏó×ÖÃæÁ¿Ã»Ê²Ã´Çø±ð,µ«Õâ¸ö°ü×°º¯Êý´´½¨ÁËÒ»¸ö¿ÉÒÔÓÃÀ´Ìí¼Ó˽ÓóÉÔ±µÄ±Õ°ü,ÈκÎÌí¼ÓÔÚÕâ¸öÄäÃûº¯ÊýÖжø²»ÔÚ¶ÔÏó×ÖÃæÁ¿Öеͼ½«³ÉΪ˽ÓгÉÔ±
MyNamespace.Singleton = (function(){
//Private members
var p1 = false;
var p2 = 10;
function p3(){}
return {
//Public members
pub1 : true,
pub2 : 10,
pub3 : functi


Ïà¹ØÎĵµ£º

JavaScriptÌØÐÔ×ܽá

1.js²»Ö§³ÖÖØÔØ£¬ÒòΪjsÀïµÄº¯Êý¶¼ÊÇÒ»¸ö¶ÔÏó£¬jsÀïÓиöÒþº¬¶ÔÏóFunction,ËùÓеÄjsº¯Êý¶¼ÊÇÒ»¸öFunctionÀàÐ͵ĶÔÏó¡£±ÈÈ磺
Java´úÂë
function add(number)   
{   
   alert("hello");   
}  
function add(number)
{
alert("hello");
}
µÈ¼ÛÓ ......

JavaScript ¼Ì³ÐÏê½â1

 
¼¸ºõÿ¸ö¿ª·¢ÈËÔ±¶¼ÓÐÃæÏò¶ÔÏóÓïÑÔ£¨±ÈÈçC++¡¢C#¡¢Java£©µÄ¿ª·¢¾­Ñé¡£ ÔÚ´«Í³ÃæÏò¶ÔÏóµÄÓïÑÔÖУ¬ÓÐÁ½¸ö·Ç³£ÖØÒªµÄ¸ÅÄî - ÀàºÍʵÀý¡£
ÀඨÒåÁËÒ»ÀàÊÂÎ﹫¹²µÄÐÐΪºÍ·½·¨£»¶øÊµÀýÔòÊÇÀàµÄÒ»¸ö¾ßÌåʵÏÖ¡£ ÎÒÃÇ»¹ÖªµÀ£¬ÃæÏò¶ÔÏó±à³ÌÓÐÈý¸öÖØÒªµÄ¸ÅÄî - ·â×°¡¢¼Ì³ÐºÍ¶à̬¡£
µ«ÊÇÔÚJavaScriptµÄÊÀ½çÖУ¬ËùÓеÄÕâÒ»ÇÐÌØ ......

JavaScript ¼Ì³ÐÏê½â3

ÔÚµÚÒ»ÕÂÖУ¬ÎÒÃÇʹÓù¹Ô캯ÊýºÍÔ­Ð͵ķ½Ê½ÔÚJavaScriptµÄÊÀ½çÖÐʵÏÖÁËÀàºÍ¼Ì³Ð£¬ µ«ÊÇ´æÔںܶàÎÊÌâ¡£ÕâÒ»ÕÂÎÒÃǽ«»áÖðÒ»·ÖÎöÕâЩÎÊÌ⣬²¢¸ø³ö½â¾ö·½°¸¡£
×¢£º±¾ÕÂÖеÄjClassµÄʵÏֲο¼ÁËSimple JavaScript Inheritance
µÄ×ö·¨¡£
Ê×ÏÈÈÃÎÒÃÇÀ´»Ø¹ËһϵÚÒ»ÕÂÖнéÉܵÄÀý×Ó£º
function Person(name) {
this.name = nam ......

JavaScript¿Í»§¶Ëд¶þ½øÖÆÎļþ(ת)

 JavaScript¿ÉÒÔÔÚ¿Í»§¶ËʵÏֺܶàÓÐÓõĽ»»¥¶¯×÷¡£Í¨¹ýµ÷ÓÃActive×é¼þ£¬»¹ÄܽøÒ»²½ÌáÉý²Ù×÷ÄÜÁ¦¡£ÔÚ¿Í»§¶ËдÎļþÒ»°ãʹÓÃFSO×é¼þ¡£µ«FSOÓиöÈõµã£¬¾ÍÊÇËü²»ÄÜд³ö¶þ½øÖƵÄÎļþ£¬Õâ¿ÉÄÜÊdzöÓÚ°²È«µÄ¿¼Âǰɡ£
    Èç¹ûҪд³ö¶þ½øÖÆÎļþ£¬±ÈÈç´Ó·þÎñÆ÷´«À´µÄWordÎĵµ£¬¿ÉÒÔ²ÉÓÃÁíÒ»¸ö×é¼þ£ºAdodb.Stream¡ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ