javascript»ù´¡Ñ§Ï°£¨ËÄ£©
Jsѧϰ£¨ËÄ£©
Èç¹ûµ±Ç°ÕýÔÚÖ´ÐеÄÊÇÒ»¸ö·½·¨£¬ÔòÖ´ÐÐÉÏÏÂÎľÍÊǸ÷½·¨Ëù¸½ÊôµÄ¶ÔÏó£¬Èç¹ûµ±Ç°ÕýÔÚÖ´ÐеÄÊÇÒ»¸ö´´½¨¶ÔÏ󣨾ÍÊÇͨ¹ý new À´´´½¨£©µÄ¹ý³Ì£¬Ôò´´½¨µÄ¶ÔÏó¾ÍÊÇÖ´ÐÐÉÏÏÂÎÄ¡£
Èç¹ûÒ»¸ö·½·¨ÔÚÖ´ÐÐʱûÓÐÃ÷È·µÄ¸½ÊôÓÚÒ»¸ö¶ÔÏó£¬ÔòËüµÄÖ´ÐÐÉÏÏÂÎÄÊÇÈ«¾Ö¶ÔÏ󣨶¥¼¶¶ÔÏ󣩣¬µ«Ëü²»Ò»¶¨¸½ÊôÓÚÈ«¾Ö¶ÔÏó¡£È«¾Ö¶ÔÏóÓɵ±Ç°»·¾³À´¾ö¶¨¡£ÔÚä¯ÀÀÆ÷»·¾³Ï£¬È«¾Ö¶ÔÏó¾ÍÊÇ window ¶ÔÏó¡£
¶¨ÒåÔÚËùÓк¯ÊýÖ®ÍâµÄÈ«¾Ö±äÁ¿ºÍÈ«¾Öº¯Êý¸½ÊôÓÚÈ«¾Ö¶ÔÏ󣬶¨ÒåÔÚº¯ÊýÄڵľֲ¿±äÁ¿ºÍ¾Ö²¿º¯Êý²»¸½ÊôÓÚÈκζÔÏó¡£
ÄÇÖ´ÐÐÉÏÏÂÎĸú±äÁ¿×÷ÓÃÓòÓÐûÓйØϵÄØ£¿
Ö´ÐÐÉÏÏÂÎÄÓë±äÁ¿×÷ÓÃÓòÊDz»Í¬µÄ¡£
Ò»¸öº¯Êý¸³Öµ¸øÁíÒ»¸ö±äÁ¿Ê±£¬Õâ¸öº¯ÊýµÄÄÚ²¿ËùʹÓõıäÁ¿µÄ×÷ÓÃÓò²»»á¸Ä±ä£¬µ«ËüµÄÖ´ÐÐÉÏÏÂÎÄ»á±äΪÕâ¸ö±äÁ¿Ëù¸½ÊôµÄ¶ÔÏó£¨Èç¹ûÕâ¸ö±äÁ¿Óи½Êô¶ÔÏóµÄ»°£©¡£
Function ÔÐÍÉ쵀 call ºÍ apply ·½·¨¿ÉÒԸıäÖ´ÐÐÉÏÏÂÎÄ£¬µ«ÊÇͬÑù²»»á¸Ä±ä±äÁ¿×÷ÓÃÓò¡£
ÒªÀí½âÉÏÃæÕâЩ»°£¬ÆäʵֻÐèÒª¼Çסһµã£º
±äÁ¿×÷ÓÃÓòÊÇÔÚ¶¨Òåʱ¾ÍÈ·¶¨µÄ£¬ËüÓÀÔ¶²»»á±ä£»¶øÖ´ÐÐÉÏÏÂÎÄÊÇÔÚÖ´ÐÐʱ²ÅÈ·¶¨µÄ£¬ËüËæʱ¿ÉÒԱ䡣
ÕâÑùÎÒÃǾͲ»ÄÑÀí½âÉÏÃæÄǸöÀý×ÓÁË¡£this.method1() ÕâÌõÓï¾ä£¨×¢Ò⣬ÕâÀï˵µÄ»¹Ã»ÓнøÈëÕâ¸öº¯ÊýÌ壩ִÐÐʱ£¬ÕýÔÚ´´½¨¶ÔÏó£¬Äǵ±Ç°µÄÖ´ÐÐÉÏÏÂÎľÍÊÇÕâ¸öÕýÔÚ´´½¨µÄ¶ÔÏó£¬ËùÒÔ this Ö¸ÏòµÄÒ²Êǵ±Ç°ÕýÔÚ´´½¨µÄ¶ÔÏó£¬ÔÚ this.method1() Õâ¸ö·½·¨Ö´ÐÐʱ£¨ÕâÀïÊÇÖ¸½øÈ뺯ÊýÌ壩£¬Õâ¸öÕýÔÚÖ´Ðеķ½·¨Ëù¸½ÊôµÄ¶ÔÏóÒ²ÊÇÕâ¸öÕýÔÚ´´½¨µÄ¶ÔÏó£¬ËùÒÔ£¬ËüÀïÃæ this.x µÄ this Ò²ÊÇͬһ¸ö¶ÔÏó£¬ËùÒÔÄã¿´µÄÊä³ö¾ÍÊÇ I’m a object variable! ÁË¡£
¶øÔÚÖ´ÐÐ method1() Õâ¸öº¯Êýʱ£¨ÊÇÖ¸½øÈ뺯ÊýÌåºó£©£¬method1() ûÓÐÃ÷È·µÄ¸½ÊôÓÚÒ»¸ö¶ÔÏó£¬ËäÈ»ËüÊǶ¨ÒåÔÚ class1 Öеģ¬µ«ÊÇËû²¢Ã»Óв»ÊǸ½ÊôÓÚ class1 µÄ£¬Ò²²»ÊǸ½ÊôÓÚ class1 ʵÀý»¯ºóµÄ¶ÔÏóµÄ£¬Ö»ÊÇËüµÄ×÷ÓÃÓò±»ÏÞÖÆÔÚÁË class1 µ±ÖС£Òò´Ë£¬ËüµÄ¸½Êô¶ÔÏóʵ¼ÊÉÏÊÇÈ«¾Ö¶ÔÏó£¬Òò´Ë£¬µ±ÔÚËüµ±ÖÐÖ´Ðе½ alert(this.x) ʱ£¬this.x ¾Í³ÉÁËÎÒÃÇÔÚÈ«¾Ö»·¾³Ï¶¨ÒåµÄÄǸöֵΪ “I’m a global variable!” µÄ x ÁË¡£
method2() ËäÈ»ÊÇÔÚ class1 Öж¨ÒåµÄ£¬µ«ÊÇ method() ÊÇÔÚ class1 Ö®ÍⶨÒåµÄ£¬method ±»¸³Öµ¸ø method2 ʱ£¬²¢Ã»Óиıä method µÄ×÷ÓÃÓò£¬ËùÒÔ£¬ÔÚ method2 Ö´ÐÐʱ£¬ÈÔÈ»ÊÇÔÚ method ±»¶¨ÒåµÄ×÷ÓÃÓòÄÚÖ´Ðеģ¬Òò´Ë£¬Äã¿´µ½µÄ¾ÍÊÇÁ½¸ö I’m a global variable! Êä³öÁË¡£Í¬Ñù£¬this.method2() µ÷ÓÃʱ£¬alert(x)
Ïà¹ØÎĵµ£º
.h Îļþ
class CHtmlSkinDlg : public CDHtmlDialog
{
¡£¡£¡£¡£¡£
DECLARE_DISPATCH_MAP()
// !!! ¸²¸Ç»ùÀàµÄÕâ¸ö·½·¨
BOOL CanAccessExternal()
{
......
JSON => String:
function jsonToString(obj){
var THIS = this;
switch(typeof(obj)){
case 'string':
return '"' + obj.replace(/(["\\])/g, '\\$1') + '"';
case 'array':
return '[' + obj.map(THIS.jsonToStri ......
¶Ô³õѧÕßÓ¦¸Ã»áÓаïÖúËùÒÔתÔØÁË¡£
ÕâÈý¸öÓïÑÔ·Ö±ðÊÇÈý¸ö¹«Ë¾¿ª·¢µÄ£¬SUNµÄJava£¬NetscapeµÄJavaScript£¬MicrosoftµÄJScript
JavaScriptÊÇÓÉNetscape¹«Ë¾¿ª·¢²¢ËæNavigatorµ¼º½ÕßÒ»Æð·¢²¼µÄ¡¢½éÓÚJavaÓëHTMLÖ®¼ä¡¢»ùÓÚ¶ÔÏóʼþÇý¶¯µÄ±à³ÌÓïÑÔ£¬²»ÐèÒªJava±àÒëÆ÷£¬¶øÊÇÖ±½ÓÔËÐÐÔÚWebä¯ÀÀÆ÷ÖУ¬ËüµÄÇ°ÉíÊÇLive Script¡£
......
JavaScriptÔÊÐí´´½¨ºÍ´ò¿ª´ú±íHTMLÎı¾, form¶ÔÏóºÍframeµÄ´°¿Ú. window¶ÔÏóÊÇJavaScript¿Í»§²ã´Î½á¹¹µÄ×²ã¶ÔÏó, formÔªËغÍÈ«²¿JavaScript´úÂ붼ÊÇ´æÔÚÓÚÎĵµÖÐ,¶øÎĵµ±»×°Ôؽø´°¿Ú. ΪÁËÀí½â´°¿ÚÔõÑù¹¤×÷,Äã¿ÉÒÔ¿ØÖƲÙ×÷ÕâЩ´°¿Ú.
´ò¿ªºÍ¹Ø±Õ´°¿Ú
µ±Óû§Æô¶¯(launch)Navigatorʱ,½«×Ô¶¯´´½¨Ò»¸ö´°¿Ú.Óû§»¹¿ÉÒÔÊ¹Ó ......
Jsѧϰ£¨Èý£©
ÁíÍâÒ»ÖÖ·½Ê½Í¨¹ýÖ±½ÓʵÀý»¯ÄäÃûº¯Êý·½Ê½À´´´½¨´øÓÐ˽Óо²Ì¬³ÉÔ±µÄÀàµÄÀý×Ó¸úÉÏÃæµÄÀý×ÓºÜÏàËÆ£º
new function() {
// private static fields
var s_first = 1;
var s_second = 2;
// private static methods
&n ......