当前位置:网站首页>JS实现私有属性
JS实现私有属性
2022-04-23 05:53:00 【KK要继续努力】
JS实现私有属性
- 基于闭包
function P(name){
var _name = name;
this.getName=function(){
return _name;
}
}
var p = new P("xxx");
console.log(p._name); //undefined
console.log(p.getName()); //xxx
版权声明
本文为[KK要继续努力]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_45393020/article/details/117933280
边栏推荐
- FOC电机库 定点PID代码分析
- 2020 Jiangsu Collegiate Programming Contest-A.Array
- 对象的动态建立和释放,赋值和复制
- realsense 选型大对比D455 D435i D415 T265 3D硬件对比
- Generate shortcut
- Initialization of classes and objects (constructors and destructors)
- MOS管特性和导通过程
- 修改注册表的值
- [UDS unified diagnostic service] IV. typical diagnostic service (2) - data transmission function unit
- _findnext 报错
猜你喜欢
CUDA environment installation
cuda工程更换环境(电脑)后遇到的一系列编译问题
2020 Jiangsu Collegiate Programming Contest-A.Array
PN结、二极管原理详解与应用
锚点定位——如何设置锚点居页面顶部距离,锚点定位并距离顶部一定偏移
FOC电机库 定点PID代码分析
CUDA project encountered a series of compilation problems after changing the environment (computer)
说说ts的心里话
Introduction to nonparametric camera distortion model
[UDS unified diagnostic service] i. overview of diagnosis (4) - basic concepts and terms
随机推荐
查漏补缺(五)
JS高频面试题
C语言实用小技巧合集(持续更新)
基于TensorFlow的线性回归实例
Assembler 32-bit unsigned addition calculator
在MFC中使用printf
2020 Jiangsu Collegiate Programming Contest-A.Array
realsense 选型大对比D455 D435i D415 T265 3D硬件对比
软件工程中的十三种文档
cv_bridge 与opencv 版本不匹配的解决
CUDA project encountered a series of compilation problems after changing the environment (computer)
JS中 t, _ => 的解析
Krypton zeal
Interprocess communication - mutex
sqlite3加密版
友元函数,友元类,类模板
Makefile基础、常用函数及通用Makefile
锚点定位——如何设置锚点居页面顶部距离,锚点定位并距离顶部一定偏移
Vs can be compiled, but there will be a red underline to indicate the problem of undefined identifiers
浮点数双精度,单精度以及半精度知识总结