久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <bdo id='EKAhb'></bdo><ul id='EKAhb'></ul>
    <tfoot id='EKAhb'></tfoot>

    <legend id='EKAhb'><style id='EKAhb'><dir id='EKAhb'><q id='EKAhb'></q></dir></style></legend>

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

    2. <i id='EKAhb'><tr id='EKAhb'><dt id='EKAhb'><q id='EKAhb'><span id='EKAhb'><b id='EKAhb'><form id='EKAhb'><ins id='EKAhb'></ins><ul id='EKAhb'></ul><sub id='EKAhb'></sub></form><legend id='EKAhb'></legend><bdo id='EKAhb'><pre id='EKAhb'><center id='EKAhb'></center></pre></bdo></b><th id='EKAhb'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='EKAhb'><tfoot id='EKAhb'></tfoot><dl id='EKAhb'><fieldset id='EKAhb'></fieldset></dl></div>

      1. javascript中的全局變量和window.variable有什么區別

        What#39;s the difference between a global var and a window.variable in javascript?(javascript中的全局變量和window.variable有什么區別?)
            <tbody id='iRbhO'></tbody>
          • <bdo id='iRbhO'></bdo><ul id='iRbhO'></ul>

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

                  <tfoot id='iRbhO'></tfoot>

                1. <legend id='iRbhO'><style id='iRbhO'><dir id='iRbhO'><q id='iRbhO'></q></dir></style></legend>
                  <i id='iRbhO'><tr id='iRbhO'><dt id='iRbhO'><q id='iRbhO'><span id='iRbhO'><b id='iRbhO'><form id='iRbhO'><ins id='iRbhO'></ins><ul id='iRbhO'></ul><sub id='iRbhO'></sub></form><legend id='iRbhO'></legend><bdo id='iRbhO'><pre id='iRbhO'><center id='iRbhO'></center></pre></bdo></b><th id='iRbhO'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='iRbhO'><tfoot id='iRbhO'></tfoot><dl id='iRbhO'><fieldset id='iRbhO'></fieldset></dl></div>
                  本文介紹了javascript中的全局變量和window.variable有什么區別?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在閱讀backbone.js 文檔并看到很多將屬性分配給窗口對象的代碼:

                  I'm reading the backbone.js documents and seeing a lot of code that assigns attributes to the window object:

                  window.something = "whatever";
                  

                  調用此代碼與僅分配變量并創建全局變量有什么區別,如下所示:

                  what's the difference between calling this code, and just assigning the variable and creating a global var, like this:

                  something = "whatever";
                  

                  我假設存在某種不同的范圍和/或對象所有權差異(窗口是所有者而不是所有者),但我對兩者之間的細節以及為什么我會使用窗口而不是使用它感興趣.

                  i assume there is some kind of scope different, and/or object ownership difference (window being the owner vs not) but i am interested in the detail between the two and why i would use window vs not use it.

                  推薦答案

                  沒有區別.它們都具有相同的效果(在瀏覽器中,window 是全局上下文1).

                  No difference. They both have the same effect (In the browser, where window is the global context1).

                  • window.foo = "bar"window 上設置屬性 foo.
                  • foo = "bar" 表示錯字或故意全局.
                  • window.foo = "bar" sets the property foo on window.
                  • foo = "bar" indicates either a typo or intentionally global.

                  由于我必須仔細檢查是否是拼寫錯誤,我個人認為直接設置 window.foo可讀.

                  Since I have to double check whether it's a typo or not, I personally find it more readable to set window.foo directly.

                  另外,在 ES5 嚴格模式下,foo = "bar" 是非法賦值,因為 foo 沒有被聲明并且會拋出 Error.

                  Also, in ES5 strict mode, foo = "bar" is an illegal assignment because foo is not declared and will throw a Error.

                  如注釋中所述,foo = "bar" 將在范圍鏈中查找變量 foo 并用 重新分配它"bar" 如果找到的話.如果沒有找到,它會創建一個新的全局變量.

                  As noted in the comments, foo = "bar" will look all the way up the scope chain for the variable foo and re-assign it with "bar" if it's found. If it's not found, it will create a new global variable.

                  另外,使用 window.foo = "bar" 您只是將屬性分配給對象,可以使用 delete window.foo 刪除該屬性.

                  Also with window.foo = "bar" you're just assigning a property to an object, which can be deleted using delete window.foo.

                  在 ES5 嚴格模式下 invalid delete 一個變量.

                  In ES5 strict mode it is invalid to delete a variable.

                  1 在其他環境中,例如node.js 和Web Workers,全局對象可能有另一個名稱,而window 可能根本不存在.Node.js 使用 global 而 Web Workers 使用 self.

                  1 In other environments, such as node.js and Web Workers, there may be another name for the global object and window may not exist at all. Node.js uses global and Web Workers use self.

                  這篇關于javascript中的全局變量和window.variable有什么區別?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項目中不起作用)
                  Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數據更新 Observable)
                  Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                  In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何創建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態元素 - Angular 2 amp;離子2)
                  <tfoot id='CsWHz'></tfoot>

                    <tbody id='CsWHz'></tbody>
                    <bdo id='CsWHz'></bdo><ul id='CsWHz'></ul>

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

                      1. <legend id='CsWHz'><style id='CsWHz'><dir id='CsWHz'><q id='CsWHz'></q></dir></style></legend>

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

                            主站蜘蛛池模板: 视频一区中文字幕 | 日韩一区二区三区在线观看 | 人干人操| 日本一本在线 | 精品日韩一区二区 | 久草.com | 嫩草视频在线 | 精品久久久久久亚洲精品 | 久久精品69| 国产日韩一区二区三区 | 久久久久久久久久一区 | 久久99精品久久久久久琪琪 | 99精品国产一区二区青青牛奶 | 中文字幕福利视频 | 欧美日韩一区在线播放 | 国产传媒视频在线观看 | 日韩av.com| 伊人超碰 | 色综合久久88色综合天天 | 激情在线视频网站 | 日本天天操| 欧美一区二区三区大片 | 欧美电影免费网站 | 一区视频 | 精品久久久久一区二区国产 | 91久久北条麻妃一区二区三区 | 久久蜜桃av | 精品国产一区二区三区在线观看 | 爱综合| 国产视频不卡一区 | 色综合天天天天做夜夜夜夜做 | 激情小视频 | 中文字幕在线一 | 日韩中文字幕一区 | 日韩一区二区三区在线观看 | 一区二区三区播放 | 亚洲精品视频免费 | 欧美综合一区 | 国产成人在线一区二区 | 久久精彩视频 | 国产一区二区在线免费观看 |