当前位置:网站首页>利用闭包实现私有变量
利用闭包实现私有变量
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;
}
})();
边栏推荐
- Mysql8.0 learning record 17 -create table
- How to solve the problem of fixed assets management and inventory?
- Daily practice of C language - day 80: currency change
- MySQL optimization
- Redis——Lettuce连接redis集群
- 【pytorch】transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
- phpexcel 里 获取某一列的列表 获取某一列的字母
- 安装Oracle EE
- pcl_viewer命令
- 2.3 【pytorch】数据预处理 torchvision.datasets.ImageFolder
猜你喜欢

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

钓鱼识别app

Mise en œuvre simple de l'équilibrage de la charge par nacos

How to manage fixed assets well? Easy to point and move to provide intelligent solutions

PR training notes

Tree structure -- binary tree 2 non recursive traversal

Understanding and implementation of AVL tree

I use flask to write the website "one"

Jetson nano installs tensorflow GPU and problem solving

【检测技术课案】简易数显电子秤的设计与制作
随机推荐
Principle and application of single chip microcomputer timer, serial communication and interrupt system
pcl_ Viewer command
[pytorch learning] torch device
Learning practice: comprehensive application of cycle and branch structure (II)
【ESP 保姆级教程 预告】疯狂Node.js服务器篇 ——案例:ESP8266 + MQ系列 + NodeJs本地服务 + MySql存储
Common interview questions for embedded engineers 2-mcu_ STM32
Principles of Microcomputer - Introduction
Performance improvement 2-3 times! The second generation Kunlun core server of Baidu AI Cloud was launched
Day06 branch structure and cycle (III)
【pytorch】transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
Promise asynchronous programming
Flink面试题
Understand shallow replication and deep replication through code examples
How to effectively align team cognition
Meituan machine test in 2022
Databinding source code analysis
樹結構---二叉樹2非遞歸遍曆
队列的实现和应用
Shell script -while loop explanation
[ESP nanny level tutorial] crazy completion chapter - Case: ws2812 light control system based on Alibaba cloud, applet and Arduino