当前位置:网站首页>利用闭包实现私有变量
利用闭包实现私有变量
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;
}
})();
边栏推荐
- [pytorch] softmax function
- Shell script - array definition and getting array elements
- 【检测技术课案】简易数显电子秤的设计与制作
- NoSQL数据库的安装和使用
- 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
- Shell script - definition, assignment and deletion of variables
- Class loading
- Shell脚本-case in 和正则表达式
- 2.3 [pytorch] data preprocessing torchvision datasets. ImageFolder
- Graduation season, I want to tell you
猜你喜欢

nacos簡易實現負載均衡

I use flask to write the website "one"

PR training notes

Redis——Lettuce连接redis集群

Imitation of Baidu search results top navigation bar effect

樹結構---二叉樹2非遞歸遍曆

Jetson Nano 安装TensorFlow GPU及问题解决
![[interview brush 101] linked list](/img/52/d159bc66c0dbc44c1282a96cf6b2fd.png)
[interview brush 101] linked list

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

Structure de l'arbre - - - arbre binaire 2 traversée non récursive
随机推荐
R language observation log (part24) -- initialization settings
Phishing identification app
Win7 pyinstaller reports an error DLL load failed while importing after packaging exe_ Socket: parameter error
Interrupt sharing variables with other functions and protection of critical resources
Graduation season, I want to tell you
TV size and viewing distance
jeecg 重启报40001
The jar package embedded with SQLite database is deployed by changing directories on the same machine, and the newly added database records are gone
【pytorch】nn. Crossentropyloss() and nn NLLLoss()
Shell script -if else statement
Understanding and implementation of AVL tree
【pytorch】2.4 卷积函数 nn.conv2d
Class loading
【ESP 保姆级教程 预告】疯狂Node.js服务器篇 ——案例:ESP8266 + DS18B20温度传感器 +NodeJs本地服务+ MySQL数据库
Promise asynchronous programming
手指点击屏幕就模拟进入F11进入全屏
Shell script - string
tensorrt yolov5_ trt. Py comments
Shell script -read command: read data entered from the keyboard
易点易动助力企业设备高效管理,提升设备利用率