• <legend id='ZiAlI'><style id='ZiAlI'><dir id='ZiAlI'><q id='ZiAlI'></q></dir></style></legend>

      <tfoot id='ZiAlI'></tfoot>

          <bdo id='ZiAlI'></bdo><ul id='ZiAlI'></ul>

        <small id='ZiAlI'></small><noframes id='ZiAlI'>

        <i id='ZiAlI'><tr id='ZiAlI'><dt id='ZiAlI'><q id='ZiAlI'><span id='ZiAlI'><b id='ZiAlI'><form id='ZiAlI'><ins id='ZiAlI'></ins><ul id='ZiAlI'></ul><sub id='ZiAlI'></sub></form><legend id='ZiAlI'></legend><bdo id='ZiAlI'><pre id='ZiAlI'><center id='ZiAlI'></center></pre></bdo></b><th id='ZiAlI'></th></span></q></dt></tr></i><div id='ZiAlI'><tfoot id='ZiAlI'></tfoot><dl id='ZiAlI'><fieldset id='ZiAlI'></fieldset></dl></div>

        ΪʲôҪʹÓÃjavascriptº¯Êý°ü×°Æ÷(ÔÚcoffeescriptÖÐÌí¼Ó)¡°.call(this)"?

        Why use the javascript function wrapper (added in coffeescript) quot;.call(this)quot;(ΪʲôҪʹÓÃjavascriptº¯Êý°ü×°Æ÷(ÔÚcoffeescriptÖÐÌí¼Ó)¡°.call(this)?)
        • <tfoot id='IeRVU'></tfoot>
            <bdo id='IeRVU'></bdo><ul id='IeRVU'></ul>
              <tbody id='IeRVU'></tbody>

            <legend id='IeRVU'><style id='IeRVU'><dir id='IeRVU'><q id='IeRVU'></q></dir></style></legend>
              <i id='IeRVU'><tr id='IeRVU'><dt id='IeRVU'><q id='IeRVU'><span id='IeRVU'><b id='IeRVU'><form id='IeRVU'><ins id='IeRVU'></ins><ul id='IeRVU'></ul><sub id='IeRVU'></sub></form><legend id='IeRVU'></legend><bdo id='IeRVU'><pre id='IeRVU'><center id='IeRVU'></center></pre></bdo></b><th id='IeRVU'></th></span></q></dt></tr></i><div id='IeRVU'><tfoot id='IeRVU'></tfoot><dl id='IeRVU'><fieldset id='IeRVU'></fieldset></dl></div>

            1. <small id='IeRVU'></small><noframes id='IeRVU'>

                  ±¾ÎĽéÉÜÁËΪʲôҪʹÓÃjavascriptº¯Êý°ü×°Æ÷(ÔÚcoffeescriptÖÐÌí¼Ó)¡°.call(this)"?µÄ´¦Àí·½·¨£¬¶Ô´ó¼Ò½â¾öÎÊÌâ¾ßÓÐÒ»¶¨µÄ²Î¿¼¼ÛÖµ£¬ÐèÒªµÄÅóÓÑÃÇÏÂÃæËæןú°æÍøµÄС±àÀ´Ò»Æðѧϰ°É£¡

                  ÎÊÌâÃèÊö

                  µ±ÎÒʹÓÃ×îР(1.0) °æ±¾µÄ¿§·È½Å±¾Ê±£¬Ò»¸ö¼òµ¥µÄ javascript Êä³ö¿´ÆðÀ´ÏñÕâÑù(ĬÈÏÇé¿öÏÂ):

                  When I use the latest (1.0) release of coffee-script, a simple javascript output looks like this (by default):

                  (function() {
                    var a;
                    a = 1;
                  }).call(this);
                  

                  .call(this) ÓÐʲô×÷ÓÃÒÔ¼°Ìí¼ÓËüµÄÔ­ÒòÊÇʲô?

                  What does .call(this) do and what would be the reason to add it?

                  ÍƼö´ð°¸

                  ËüÕýÔÚ´´½¨Ò»¸öº¯Êý£¬È»ºóʹÓø¸º¯Êý/¶ÔÏó·¶Î§µ÷ÓÃ×ÔÉí.

                  It's creating a function and then calling itself with the parent function/objects scope.

                  .call ºÍ .apply Êǵ÷Óú¯ÊýµÄ²»Í¬·½·¨.Äú»ù±¾ÉÏ´´½¨ÁËÒ»¸öº¯Êý£¬³ýÁËÔÚ×Ô¼ºµÄ·¶Î§ÄÚÉèÖà a=1 Ö®Íâʲô¶¼²»×ö.

                  .call and .apply are different methods of invoking a function. You basically created a function that does nothing except set a=1 within its own scope.

                  ÔÚ javascript ÖÐÄãÐèÒªÒâʶµ½Ã¿¸öº¯Êý¶¼ÊÇÒ»¸ö¶ÔÏ󣬶ø this ÊÇÖ¸µ±Ç°µÄ¶ÔÏó/º¯Êý.ʹÓà .call(this) ¸²¸Çº¯ÊýÄÚµÄ this ²¢½«ÆäÌ滻Ϊµ÷ÓÃÉÏÏÂÎÄÖеÄÄǸö.

                  In javascript you need to realize that every function is a object, and this is what refers to the current object/function. Using .call(this) overrides this from within the function and replaces it with the one from the calling context.

                  Õâƪ¹ØÓÚΪʲôҪʹÓÃjavascriptº¯Êý°ü×°Æ÷(ÔÚcoffeescriptÖÐÌí¼Ó)¡°.call(this)"?µÄÎÄÕ¾ͽéÉܵ½ÕâÁË£¬Ï£ÍûÎÒÃÇÍƼöµÄ´ð°¸¶Ô´ó¼ÒÓÐËù°ïÖú£¬Ò²Ï£Íû´ó¼Ò¶à¶àÖ§³Ö¸ú°æÍø£¡

                  ±¾Õ¾²¿·ÖÄÚÈÝÀ´Ô´»¥ÁªÍø,Èç¹ûÓÐͼƬ»òÕßÄÚÈÝÇÖ·¸ÁËÄúµÄȨÒ棬ÇëÁªÏµÎÒÃÇ£¬ÎÒÃÇ»áÔÚÈ·ÈϺóµÚһʱ¼ä½øÐÐɾ³ý£¡

                  Ïà¹ØÎĵµÍƼö

                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:ÈçºÎ½« rails ±äÁ¿×¢Èë(·Ç³£)¼òµ¥µÄ javascript)
                  quot;Each child in an array should have a unique key propquot; only on first time render of page(¡°Êý×éÖеÄÿ¸öº¢×Ó¶¼Ó¦¸ÃÓÐÒ»¸öΨһµÄ key prop½öÔÚµÚÒ»´Î³ÊÏÖÒ³Ãæʱ)
                  Rails 3.1 ajax:success handling(Rails 3.1 ajax:³É¹¦´¦Àí)
                  CoffeeScript always returns in anonymous function(CoffeeScript ×ÜÊÇÒÔÄäÃûº¯Êý·µ»Ø)
                  Ordinals in words javascript(javascriptÖеÄÐòÊý)
                  getFullYear returns year before on first day of year(getFullYear ÔÚÒ»ÄêµÄµÚÒ»Ìì·µ»ØÇ°Ò»Äê)

                  <small id='E9HNd'></small><noframes id='E9HNd'>

                    <i id='E9HNd'><tr id='E9HNd'><dt id='E9HNd'><q id='E9HNd'><span id='E9HNd'><b id='E9HNd'><form id='E9HNd'><ins id='E9HNd'></ins><ul id='E9HNd'></ul><sub id='E9HNd'></sub></form><legend id='E9HNd'></legend><bdo id='E9HNd'><pre id='E9HNd'><center id='E9HNd'></center></pre></bdo></b><th id='E9HNd'></th></span></q></dt></tr></i><div id='E9HNd'><tfoot id='E9HNd'></tfoot><dl id='E9HNd'><fieldset id='E9HNd'></fieldset></dl></div>

                  • <legend id='E9HNd'><style id='E9HNd'><dir id='E9HNd'><q id='E9HNd'></q></dir></style></legend>
                    <tfoot id='E9HNd'></tfoot>

                          <bdo id='E9HNd'></bdo><ul id='E9HNd'></ul>

                              <tbody id='E9HNd'></tbody>