当前位置:网站首页>JS implementation private attribute
JS implementation private attribute
2022-04-23 17:41:00 【KK should continue to work hard】
JS Implement private properties
- Based on closure
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 should continue to work hard]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230551363620.html
边栏推荐
猜你喜欢
For the space occupation of the software, please refer to the installation directory
48. Rotate image
XTask与Kotlin Coroutine的使用对比
Double pointer advanced -- leetcode title -- container with the most water
470. 用 Rand7() 实现 Rand10()
Allowed latency and side output
958. Complete binary tree test
Use of five routing guards
Summary of common SQL statements
Kubernetes service discovery monitoring endpoints
随机推荐
JS failed to change all variables and changed to the return method. Finally, the problem was solved
[ES6] promise related (event loop, macro / micro task, promise, await / await)
JVM class loading mechanism
【Appium】通过设计关键字驱动文件来编写脚本
Shell - introduction, variables, and basic syntax
HCIP第五次实验
2.Electron之HelloWorld
Use of shell cut command
239. Maximum value of sliding window (difficult) - one-way queue, large top heap - byte skipping high frequency problem
Abnormal resolution of Xiaomi camera
练习:求偶数和、阈值分割和求差( list 对象的两个基础小题)
122. The best time to buy and sell stocks II - one-time traversal
Why do some people say SCM is simple and I have to learn it so hard?
Read software engineering at Google (15)
How does matlab draw the curve of known formula and how does excel draw the function curve image?
92. 反转链表 II-字节跳动高频题
PC电脑使用无线网卡连接上手机热点,为什么不能上网
2021 Great Wall Cup WP
一些问题一些问题一些问题一些问题
Using quartz under. Net core - calendar of [6] jobs and triggers