当前位置:网站首页>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
边栏推荐
猜你喜欢

QT icon application

基于VGG对五种类别图片的迁移学习

Qt 给应用程序加图标

Assembler 32-bit unsigned addition calculator

PN结、二极管原理详解与应用

Eigen 学习总结

FOC电机库 定点PID代码分析
![[UDS unified diagnostic service] IV. typical diagnostic service (2) - data transmission function unit](/img/22/c501c79176a93345dc72ff150c53c3.png)
[UDS unified diagnostic service] IV. typical diagnostic service (2) - data transmission function unit
[ThreadX] h743 + ThreadX + Filex migration record
VHDL arbitrary frequency divider (50% duty cycle)
随机推荐
[opencv] use filestorage to read and write eigenvectors
Interprocess communication - mutex
Log writing method (with time)
Modify registry values
Quaternion multiplication
C language advanced notes 3
Notes on advanced points of C language 4
FOC 单电阻采样 位置环控制伺服电机
Special register C51 / C52
Sdoi2009-hh Necklace
Assembler 32-bit unsigned addition calculator
浮点数双精度,单精度以及半精度知识总结
Analysis and setting of dead time
往String原型上封装一个时间戳转日期的方法
CUDA environment installation
WMI技术介绍和应用
基于VGG对五种类别图片的迁移学习
JS高频面试题
友元函数,友元类,类模板
赛氪-zeal