久久久久久久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>

                            主站蜘蛛池模板: 激情 婷婷 | 亚洲v日韩v综合v精品v | 中文字幕第十五页 | 欧美一区二区三区在线观看 | 亚洲欧美国产毛片在线 | 99re在线视频精品 | 在线久草 | 亚洲精品国产综合区久久久久久久 | 伊人久久在线 | 黄在线 | 成人午夜精品 | 欧美二区在线 | 国产乱一区二区三区视频 | 久久丝袜| 日韩三级电影一区二区 | 免费的av网站| 欧美精品久久久久久久久老牛影院 | 国产一区二区在线观看视频 | 成人高清在线 | www久久久| 国产福利在线 | 天天干狠狠操 | 成人国产午夜在线观看 | 久久国产欧美一区二区三区精品 | 国外成人免费视频 | 日韩精品一区二区三区中文在线 | 国产乱码精品一品二品 | 亚洲va在线va天堂va狼色在线 | 欧美精品久久久 | 国产欧美日韩一区二区三区在线观看 | 亚洲午夜精品 | 成人在线不卡 | 日韩三级一区 | 日本黄色免费大片 | 国产精品久久久久一区二区三区 | 在线观看视频一区二区三区 | 97色伦网 | 亚洲国产aⅴ成人精品无吗 国产精品永久在线观看 | 亚洲热在线视频 | 日韩在线一区二区三区 | 99re在线视频 |