当前位置:网站首页>利用闭包实现私有变量
利用闭包实现私有变量
2022-07-01 09:13:00 【su27_0101】
在js中不存在private 私有变量的定义,但利用闭包可以模拟
var getter, setter;
(function(){
var privateA = 0;
getter = function(){
return privateA;
};
setter = function(newVal){
if(typeof newVal != 'number'){
throw new Error("不是number")
}
privateA = newVal;
}
})();
边栏推荐
- Performance improvement 2-3 times! The second generation Kunlun core server of Baidu AI Cloud was launched
- Ape anthropology topic 20 (the topic will be updated from time to time)
- 序列化、监听、自定义注解
- [ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + MQ Series + nodejs local service + MySQL storage
- 美团2022年机试
- 【pytorch】transforms. Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
- Leetcode daily question brushing record --540 A single element in an ordered array
- Installing Oracle EE
- PR training notes
- How to manage fixed assets well? Easy to point and move to provide intelligent solutions
猜你喜欢
![[video game training] real topic of 2013 video game of infrared optical communication device](/img/ef/c2c45c1c6c24aed0a4e93101047372.png)
[video game training] real topic of 2013 video game of infrared optical communication device
![[pytorch] 2.4 convolution function nn conv2d](/img/eb/382a00af5f88d5954f10ea76343d6e.png)
[pytorch] 2.4 convolution function nn conv2d

Pain points and solutions of equipment management in large factories

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

Principle and application of single chip microcomputer timer, serial communication and interrupt system

NiO zero copy

nacos服务配置和持久化配置

Mysql 优化

How to manage fixed assets efficiently in one stop?

Redis——Lettuce连接redis集群
随机推荐
2.4 激活函数
[pytorch] softmax function
钓鱼识别app
Shell script -for loop and for int loop
【pytorch】nn. Crossentropyloss() and nn NLLLoss()
Class loading
Set the type of the input tag to number, and remove the up and down arrows
2.4 activation function
通过 代码实例 理解 浅复制 与 深复制
Interrupt sharing variables with other functions and protection of critical resources
【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于物联网的GY906红外测温门禁刷卡系统
【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于阿里云、小程序、Arduino的温湿度监控系统
LogBack
Shell script - positional parameters (command line parameters)
Implementation and application of queue
Daily office consumables management solution
2.3 【pytorch】数据预处理 torchvision.datasets.ImageFolder
2.3 [pytorch] data preprocessing torchvision datasets. ImageFolder
[pytorch learning] torch device
Simple load balancing with Nacos