当前位置:网站首页>利用闭包实现私有变量
利用闭包实现私有变量
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;
}
})();
边栏推荐
- An overview of the design of royalties and service fees of mainstream NFT market platforms
- Principles of Microcomputer - internal and external structure of microprocessor
- Phishing identification app
- Tree structure --- binary tree 1
- Shell脚本-case in 和正则表达式
- Flink interview questions
- PR training notes
- Imitation of Baidu search results top navigation bar effect
- Graduation season, I want to tell you
- Pain points and solutions of fixed assets management of group companies
猜你喜欢
![[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

Daily practice of C language - day 80: currency change

dsPIC30F6014a LCD 方块显示

Jetson Nano 安装TensorFlow GPU及问题解决

小鸟识别APP

Pain points and solutions of equipment management in large factories

I use flask to write the website "one"

2.4 activation function

Vsync+ triple cache mechanism +choreographer

nacos簡易實現負載均衡
随机推荐
Vsync+ triple cache mechanism +choreographer
【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于阿里云、小程序、Arduino的温湿度监控系统
猿人学第20题(题目会不定时更新)
jeecg 重启报40001
类加载
Structure de l'arbre - - - arbre binaire 2 traversée non récursive
Jetson Nano 安装TensorFlow GPU及问题解决
Redis -- lattice connects to redis cluster
Day06 branch structure and cycle (III)
Leetcode daily question brushing record --540 A single element in an ordered array
【ESP 保姆级教程 预告】疯狂Node.js服务器篇 ——案例:ESP8266 + DS18B20温度传感器 +NodeJs本地服务+ MySQL数据库
The fixed assets management system enables enterprises to dynamically master assets
Shell script - positional parameters (command line parameters)
Redis source code learning (29), compressed list learning, ziplist C (II)
Learning practice: comprehensive application of cycle and branch structure (II)
Shell script - array definition and getting array elements
LogBack
2.3 [pytorch] data preprocessing torchvision datasets. ImageFolder
Shell脚本-变量的定义、赋值和删除
通过 代码实例 理解 浅复制 与 深复制