当前位置:网站首页>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
边栏推荐
- 日志写法(带时间)
- 汇编 32位无符号加法计算器
- Round up a little detail of the round
- 导入文件时候 new FormData()
- VHDL finite state machine (FSM) code example
- 金额输入框,用于充值提现
- QT add qserialport class to realize serial port operation
- [UDS unified diagnosis service] IV. typical diagnosis service (1) - diagnosis and communication management function unit
- HDU-Tunnel Warfare
- 2022LDU寒假训练-程序补丁
猜你喜欢
Introduction to nonparametric camera distortion model
Makefile基础、常用函数及通用Makefile
[UDS unified diagnosis service] i. diagnosis overview (2) - main diagnosis protocols (K-line and can)
js根据名字将数组对象中名字相同的项组成一个相同的数组
欢迎使用Markdown编辑器
QT add qserialport class to realize serial port operation
基于TensorFlow的线性回归实例
CUDA project encountered a series of compilation problems after changing the environment (computer)
FOC 单电阻采样 位置环控制伺服电机
cv_bridge 与opencv 版本不匹配的解决
随机推荐
CUDA environment installation
说说ts的心里话
Joseph sequence segment tree o (nlogn)
ES6
[UDS unified diagnostic service] IV. typical diagnostic service (2) - data transmission function unit
VHDL arbitrary frequency divider (50% duty cycle)
Generate random number
往String原型上封装一个时间戳转日期的方法
CUDA project encountered a series of compilation problems after changing the environment (computer)
Modify registry values
Understanding of SSH public key and private key
js根据名字将数组对象中名字相同的项组成一个相同的数组
[UDS unified diagnosis service] IV. typical diagnosis service (1) - diagnosis and communication management function unit
C语言 #和##的使用
Declared as a global variable
C51/C52 特殊功能寄存器表
QT add qserialport class to realize serial port operation
C语言进阶要点笔记4
TP download folder, compress folder and download
SSH 公钥 私钥的理解