pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

      <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="02m2akw" id='EKAhb'><tfoot id='EKAhb'></tfoot><dl id='EKAhb'><fieldset id='EKAhb'></fieldset></dl></div>

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

        What#39;s the difference between a global var and a window.variable in javascript?(javascript中的全局變量和window.variable有什么區(qū)別?)
            <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="s00gouk" id='iRbhO'><tfoot id='iRbhO'></tfoot><dl id='iRbhO'><fieldset id='iRbhO'></fieldset></dl></div>
                  本文介紹了javascript中的全局變量和window.variable有什么區(qū)別?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在閱讀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";
                  

                  調用此代碼與僅分配變量并創(chuàng)建全局變量有什么區(qū)別,如下所示:

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

                  something = "whatever";
                  

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

                  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.

                  推薦答案

                  沒有區(qū)別.它們都具有相同的效果(在瀏覽器中,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" 如果找到的話.如果沒有找到,它會創(chuàng)建一個新的全局變量.

                  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 在其他環(huán)境中,例如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有什么區(qū)別?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  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 - 使用異步數(shù)據(jù)更新 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 中,如何創(chuàng)建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態(tài)元素 - 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="mg0msqo" id='CsWHz'><tfoot id='CsWHz'></tfoot><dl id='CsWHz'><fieldset id='CsWHz'></fieldset></dl></div>

                            主站蜘蛛池模板: 台湾阳明固态继电器-奥托尼克斯光电传感器-接近开关-温控器-光纤传感器-编码器一级代理商江苏用之宜电气 | 楼承板设备-楼承板成型机-免浇筑楼承板机器厂家-捡来 | 衬塑管道_衬四氟管道厂家-淄博恒固化工设备有限公司 | 一氧化氮泄露报警器,二甲苯浓度超标报警器-郑州汇瑞埔电子技术有限公司 | 尼龙PA610树脂,尼龙PA612树脂,尼龙PA1010树脂,透明尼龙-谷骐科技【官网】 | 防爆大气采样器-防爆粉尘采样器-金属粉尘及其化合物采样器-首页|盐城银河科技有限公司 | 深圳3D打印服务-3D打印加工-手板模型加工厂-悟空打印坊 | 华东师范大学在职研究生招生网_在职研究生招生联展网 | 江西自考网 | Eiafans.com_环评爱好者 环评网|环评论坛|环评报告公示网|竣工环保验收公示网|环保验收报告公示网|环保自主验收公示|环评公示网|环保公示网|注册环评工程师|环境影响评价|环评师|规划环评|环评报告|环评考试网|环评论坛 - Powered by Discuz! | 连续密炼机_双转子连续密炼机_连续式密炼机-南京永睿机械制造有限公司 | 传动滚筒_厂家-淄博海恒机械制造厂 | lcd条形屏-液晶长条屏-户外广告屏-条形智能显示屏-深圳市条形智能电子有限公司 | 湖南长沙商标注册专利申请,长沙公司注册代理记账首选美创! | _网名词典_网名大全_qq网名_情侣网名_个性网名 | 空冷器|空气冷却器|空水冷却器-无锡赛迪森机械有限公司[官网] | 购买舔盐、舔砖、矿物质盐压块机,鱼饵、鱼饲料压块机--请到杜甫机械 | 没斑啦-专业的祛斑美白嫩肤知识网站-去斑经验分享 | 滑石粉,滑石粉厂家,超细滑石粉-莱州圣凯滑石有限公司 | nalgene洗瓶,nalgene量筒,nalgene窄口瓶,nalgene放水口大瓶,浙江省nalgene代理-杭州雷琪实验器材有限公司 | 不锈钢电动球阀_气动高压闸阀_旋塞疏水调节阀_全立阀门-来自温州工业阀门巨头企业 | 实验室隔膜泵-无油防腐蚀隔膜泵-耐腐蚀隔膜真空泵-杭州景程仪器 电杆荷载挠度测试仪-电杆荷载位移-管桩测试仪-北京绿野创能机电设备有限公司 | 齿辊分级破碎机,高低压压球机,立式双动力磨粉机-郑州长城冶金设备有限公司 | 杭州顺源过滤机械有限公司官网-压滤机_板框压滤机_厢式隔膜压滤机厂家 | 电脑知识|软件|系统|数据库|服务器|编程开发|网络运营|知识问答|技术教程文章 - 好吧啦网 | 高尔夫球杆_高尔夫果岭_高尔夫用品-深圳市新高品体育用品有限公司 | 烟气换热器_GGH烟气换热器_空气预热器_高温气气换热器-青岛康景辉 | 大功率金属激光焊接机价格_不锈钢汽车配件|光纤自动激光焊接机设备-东莞市正信激光科技有限公司 定制奶茶纸杯_定制豆浆杯_广东纸杯厂_[绿保佳]一家专业生产纸杯碗的厂家 | 可程式恒温恒湿试验箱|恒温恒湿箱|恒温恒湿试验箱|恒温恒湿老化试验箱|高低温试验箱价格报价-广东德瑞检测设备有限公司 | 防火门-专业生产甲级不锈钢钢质防火门厂家资质齐全-广东恒磊安防设备有限公司 | 微波消解仪器_智能微波消解仪报价_高压微波消解仪厂家_那艾 | 接地电阻测试仪[厂家直销]_电缆故障测试仪[精准定位]_耐压测试仪-武汉南电至诚电力设备 | 低温柔性试验仪-土工布淤堵-沥青车辙试验仪-莱博特(天津)试验机有限公司 | 大立教育官网-一级建造师培训-二级建造师培训-造价工程师-安全工程师-监理工程师考试培训 | 微型气象仪_气象传感器_防爆气象传感器-天合传感器大全 | 帽子厂家_帽子工厂_帽子定做_义乌帽厂_帽厂_制帽厂_帽子厂_浙江高普制帽厂 | 万师讲师网-优质讲师培训师供应商,讲师认证,找讲师来万师 | 绿叶|绿叶投资|健康产业_绿叶投资集团有限公司 | 北京三友信电子科技有限公司-ETC高速自动栏杆机|ETC机柜|激光车辆轮廓测量仪|嵌入式车道控制器 | 特种电缆厂家-硅橡胶耐高温电缆-耐低温补偿导线-安徽万邦特种电缆有限公司 | 深圳快餐店设计-餐饮设计公司-餐饮空间品牌全案设计-深圳市勤蜂装饰工程 |