当前位置:网站首页>ES6 decoupling top-level objects from windows
ES6 decoupling top-level objects from windows
2022-07-01 09:17:00 【su27_ 0101】
What is a top-level object
Also called global object Globally accessible objects Such as : window.a = 123 a Is the top-level object
however , In the browser, the top-level object is window self,Node In Chinese, it means global
Top level objects and window The disadvantages of dependence
- Leading to easy abuse of top-level objects , Cause object conflict
Such asYou define a=2Andwindow.a =2It's the same , It automatically becomes a variable mounted on the top-level object - Not conducive to modularity : The idea of modularity is Local definition Just want to expose the least content globally
es6 How to avoid top-level objects and window rely on
- Use
const letAnd Block level action to avoid When declaring variables directly Hang upwindow
let b = 1;
window.b // undefined
边栏推荐
- js函数arguments对象
- Common interview questions for embedded engineers 2-mcu_ STM32
- LogBack
- Shell script - string
- 树结构---二叉树2非递归遍历
- Flink面试题
- How to manage fixed assets well? Easy to point and move to provide intelligent solutions
- 3D打印Arduino 四轴飞行器
- Leetcode daily question brushing record --540 A single element in an ordered array
- 2.2 【pytorch】torchvision.transforms
猜你喜欢

Redis——Lettuce连接redis集群

Installation and use of NoSQL database

Vsync+ triple cache mechanism +choreographer

2.3 【pytorch】数据预处理 torchvision.datasets.ImageFolder

Bird recognition app

2.3 【kaggle数据集 - dog breed 举例】数据预处理、重写Dataset、DataLoader读取数据

Implementation and application of queue

Daily practice of C language - day 80: currency change

How to solve the problem of fixed assets management and inventory?

Simple load balancing with Nacos
随机推荐
Promise asynchronous programming
Ranking list of domestic databases in February, 2022: oceanbase regained the "three consecutive increases", and gaussdb is expected to achieve the largest increase this month
js valueOf 与 toString 区别
樹結構---二叉樹2非遞歸遍曆
手指点击屏幕就模拟进入F11进入全屏
pcl_ Viewer command
2.3 【pytorch】数据预处理 torchvision.datasets.ImageFolder
How to manage fixed assets well? Easy to point and move to provide intelligent solutions
Imitation of Baidu search results top navigation bar effect
Principles of Microcomputer - Introduction
Simple load balancing with Nacos
【pytorch】transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
Key points of NFT supervision and overseas policies
Win7 pyinstaller reports an error DLL load failed while importing after packaging exe_ Socket: parameter error
Shell script -while loop explanation
R language observation log (part24) -- initialization settings
Niuke monthly race 22- collect pieces of paper
How to effectively align team cognition
2.4 activation function
Shell script - special variables: shell $, $*, [email protected], $$$